From 54e1409a21dc9344774c14b8f448ea3029e2d088 Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Tue, 30 Jul 2024 15:15:33 +0200 Subject: [PATCH] Hardcode collation example (#268) Closes #266 --- R/collate.R | 10 ++++++++-- man/with_collate.Rd | 12 +++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/R/collate.R b/R/collate.R index a59f5666..3214dfb5 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 6f4436c0..222fd63e 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 }