chartr                 package:base                 R Documentation

_C_h_a_r_a_c_t_e_r _T_r_a_n_s_l_a_t_i_o_n _a_n_d _C_a_s_e_f_o_l_d_i_n_g

_D_e_s_c_r_i_p_t_i_o_n:

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

_U_s_a_g_e:

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

_A_r_g_u_m_e_n_t_s:

       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?.

_D_e_t_a_i_l_s:

     `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
     repreated 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.

_S_e_e _A_l_s_o:

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

_E_x_a_m_p_l_e_s:

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

