make.names               package:base               R Documentation

_M_a_k_e _S_y_n_t_a_c_t_i_c_a_l_l_y _V_a_l_i_d _N_a_m_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     Make syntactically valid names out of character vectors.

_U_s_a_g_e:

     make.names(names, unique = FALSE)

_A_r_g_u_m_e_n_t_s:

   names: character vector to be coerced to syntactically valid names.
          This is coerced to character if necessary.

  unique: logical; if 'TRUE', the resulting elements are unique.  This
          may be desired for, e.g., column names.

_D_e_t_a_i_l_s:

     A syntactically valid name consists of letters, numbers, and the
     dot character and starts with a letter or the dot.  Names such as
     '".2"' are not valid, and neither are the reserved words.

     The character '"X"' is prepended if necessary. All invalid
     characters are translated to '"."'.  A missing value is translated
     to '"NA"'.  Names which match R keywords have a dot appended to
     them.  Duplicated values are altered by 'make.unique'.

_V_a_l_u_e:

     A character vector of same length as 'names' with each changed to
     a syntactically valid name.

_S_e_e _A_l_s_o:

     'make.unique', 'names', 'character', 'data.frame'.

_E_x_a_m_p_l_e_s:

     make.names(c("a and b", "a_and_b"), unique=TRUE)
     # "a.and.b"  "a.and.b.1"

     data(state)
     state.name[make.names(state.name) != state.name] # those 10 with a space

