diff --git a/R/collate.R b/R/collate.R index a59f566..3214dfb 100644 --- a/R/collate.R +++ b/R/collate.R @@ -6,13 +6,19 @@ #' @template with #' @param new `[character(1)]`\cr New collation order #' @param .local_envir `[environment]`\cr The environment to use for scoping. -#' @examples +#' +#' @section Examples: #' +#' ``` #' # Modify collation order: #' x <- c("bernard", "bérénice", "béatrice", "boris") +#' #' with_collate("fr_FR", sort(x)) -#' with_collate("C", sort(x)) +#' #> [1] "béatrice" "bérénice" "bernard" "boris" #' +#' with_collate("C", sort(x)) +#' #> [1] "bernard" "boris" "béatrice" "bérénice" +#' ``` #' @export with_collate <- function(new, code) { with_locale(c(LC_COLLATE = new), code) diff --git a/man/with_collate.Rd b/man/with_collate.Rd index 6f4436c..222fd63 100644 --- a/man/with_collate.Rd +++ b/man/with_collate.Rd @@ -24,14 +24,20 @@ argument. Temporarily change collation order by changing the value of the \code{LC_COLLATE} locale. } -\examples{ +\section{Examples}{ -# Modify collation order: + +\if{html}{\out{
}}\preformatted{# Modify collation order: x <- c("bernard", "bérénice", "béatrice", "boris") + with_collate("fr_FR", sort(x)) -with_collate("C", sort(x)) +#> [1] "béatrice" "bérénice" "bernard" "boris" +with_collate("C", sort(x)) +#> [1] "bernard" "boris" "béatrice" "bérénice" +}\if{html}{\out{
}} } + \seealso{ \code{\link{withr}} for examples }