| strtrans | R Documentation |
These functions can be used to translate characters, including case mapping and folding, script to script conversion, and Unicode normalisation.
strtrans(x, transform)
chartr2(x, pattern, replacement)
chartr(old, new, x)
tolower(x, locale = NULL)
toupper(x, locale = NULL)
casefold(x, upper = NA)
x |
character vector (or an object coercible to) |
transform |
single string with ICU general transform
specifier, see |
pattern, old |
single string |
replacement, new |
single string,
preferably of the same length as |
locale |
|
upper |
single logical value; switches between case folding
(the default, |
tolower and toupper perform case mapping.
chartr2 (and [DEPRECATED] chartr) translate individual code points.
casefold commits case folding.
The new function strtrans applies general ICU transforms,
see stri_trans_general.
These functions return a character vector (in UTF-8).
They preserve most attributes of x.
Note that their base R counterparts drop all the attributes
if not fed with character vectors.
Unlike their base R counterparts, the new tolower and
toupper are locale-sensitive;
see stri_trans_tolower.
The base casefold simply dispatches to
tolower or toupper
'for compatibility with S-PLUS' (which was only crucial long time ago).
The version implemented here, by default, performs the true case folding,
whose purpose is to make two pieces of text that differ only in case
identical, see stri_trans_casefold.
chartr2 and [DEPRECATED] chartr are
wrappers for stri_trans_char.
Contrary to the base chartr, they always generate
a warning when old and new are of different lengths.
chartr2 has argument order and naming consistent with
gsub.
The official online manual of stringx at https://stringx.gagolewski.com/
strtrans(strcat(letters_bf), "Any-NFKD; Any-Upper")
strtrans(strcat(letters_bb[1:6]), "Any-Hex/C")
strtrans(strcat(letters_greek), "Greek-Latin")
toupper(letters_greek)
tolower(LETTERS_GREEK)
base::toupper("gro\u00DF")
stringx::toupper("gro\u00DF")
casefold("gro\u00DF")
x <- as.matrix(c(a="\u00DFpam ba\U0001D554on spam", b=NA))
chartr("\u00DF\U0001D554aba", "SCXBA", x)
toupper('i', locale='en_US')
toupper('i', locale='tr_TR')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.