Temporarily change collation order by changing the value of the LC_COLLATE locale.
LC_COLLATE
with_collate(new, code)local_collate(new = list(), .local_envir = parent.frame())
local_collate(new = list(), .local_envir = parent.frame())
[any] The results of the evaluation of the code
[any]
code
argument.
[character(1)] New collation order
[character(1)]
[any] Code to execute in the temporary environment
[environment] The environment to use for scoping.
[environment]
withr for examples
withr
# Modify collation order: x <- c("bernard", "bérénice", "béatrice", "boris") with_collate("fr_FR", sort(x)) with_collate("C", sort(x))
Run the code above in your browser using DataLab