chartr                 package:base                 R Documentation

Character Translation and Casefolding

Description:

     Translate characters in character vectors, in particular from
     upper to lower case or vice versa.

Usage:

     chartr(old, new, x)
     tolower(x)
     toupper(x)
     casefold(x, upper = FALSE)

Arguments:

       x: a character vector.

     old: a character string specifying the characters to be
          translated.

     new: a character string specifying the translations.

   upper: logical: translate to upper or lower case?.

Details:

     'chartr' translates each character in 'x' that is specified in
     'old' to the corresponding character specified in 'new'. Ranges
     are supported in the specifications, but character classes and
     repeated characters are not.  If 'old' contains more characters
     than new, an error is signaled; if it contains fewer characters,
     the extra characters at the end of 'new' are ignored.

     'tolower' and 'toupper' convert upper-case characters in a
     character vector to lower-case, or vice versa.  Non-alphabetic
     characters are left unchanged.

     'casefold' is a wrapper for 'tolower' and 'toupper' provided for
     compatibility with S-PLUS.

See Also:

     'sub' and 'gsub' for other substitutions in strings.

Examples:

     x <- "MiXeD cAsE 123"
     chartr("iXs", "why", x)
     chartr("a-cX", "D-Fw", x)
     tolower(x)
     toupper(x)

