withLocale

0th

Percentile

Evaluate an R expression with locale set temporarily

Evaluate an R expression with locale set temporarily.

Keywords
programming, IO
Usage
withLocale(expr, category, locale, ..., envir=parent.frame())
Arguments
expr
The R expression to be evaluated.
category
A character string specifying the category to use.
locale
character vector specifying the locale to used. The first successfully set one will be used.
...
Not used.
envir
The environment in which the expression should be evaluated.
Value

  • Returns the results of the expression evaluated.

See Also

Internally, eval() is used to evaluate the expression. and Sys.setlocale() to set locale.

Aliases
  • withLocale
Examples
# Vector
cat("Original vector:
")
x <- c(letters[1:8], LETTERS[1:8])
print(x)

cat("Sorting with 'C' locale:
")
y1 <- withLocale(sort(x), "LC_COLLATE", "C")
print(y1)

cat("Sorting with an 'English' locale:
")
y2 <- withLocale(sort(x), "LC_COLLATE", c("en_US", "en_US.UTF8", "English_United States.1252"))
print(y2)
Documentation reproduced from package R.utils, version 2.0.0, License: LGPL (>= 2.1)

Community examples

Looks like there are no examples yet.