Evaluate an R expression with locale set temporarily
Evaluate an R expression with locale set temporarily.
withLocale(expr, category, locale, ..., substitute=TRUE, envir=parent.frame())
expr |
The R expression to be evaluated. |
category |
A |
locale |
|
... |
Not used. |
substitute |
If |
envir |
The |
Returns the results of the expression evaluated.
Henrik Bengtsson
Internally, eval
() is used to evaluate the expression.
and Sys.setlocale
() to set locale.
# Vector cat("Original vector:\n") x <- c(letters[1:8], LETTERS[1:8]) print(x) cat("Sorting with 'C' locale:\n") y1 <- withLocale(sort(x), "LC_COLLATE", "C") print(y1) cat("Sorting with an 'English' locale:\n") y2 <- withLocale(sort(x), "LC_COLLATE", c("en_US", "en_US.UTF8", "English_United States.1252")) print(y2)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.