Rename                package:epicalc                R Documentation

_R_e_n_a_m_e _v_a_r_i_a_b_l_e(_s) _i_n _t_h_e _d_e_f_a_u_l_t _d_a_t_a _f_r_a_m_e

_D_e_s_c_r_i_p_t_i_o_n:

     Rename a variable or change a pattern of variable names.

_U_s_a_g_e:

     rename(x1, x2, dataFrame = .data, ...)

     ## Default S3 method:
     rename(x1, x2, dataFrame = .data, ...)

     ## S3 method for class 'var':
     rename(x1, x2, dataFrame = .data, ...)

     ## S3 method for class 'pattern':
     rename(x1, x2, dataFrame = .data, printNote=TRUE, ...)

     ren(x1, x2, dataFrame = .data, ...)

_A_r_g_u_m_e_n_t_s:

      x1: a variable or a pattern among the names of the variables
          inside .data.

      x2: new name or new pattern of the variable(s).

              FUNCTION          'x1'          'x2'
              'rename.var'      old variable  new variable
              'rename.pattern'  old pattern   new pattern

dataFrame: a data frame, the variable(s) of which will be renamed

printNote: whether the table of old names and new names of the
          variables(s) should be printed out.

     ...: further arguments passed to or used by other methods.

_D_e_t_a_i_l_s:

     'rename.var' renames variable 'x1' to 'x2'. Both arguments may
     have the quotes omitted.

     'rename.pattern' changes substring 'x1' in any names of variables
     inside .data to 'x2'. With 'printNote=TRUE', a table with columns
     of old and new variables will be displayed.

     'rename.var' is called if 'x1' perfectly matches with a variable
     name. 'rename.pattern' is called if the pattern 'x1' is found as a
     substring among the variable names. Otherwise, an error will
     occur.

     Finally, 'ren' is the abbreviated form of 'rename' without any
     suffix

_A_u_t_h_o_r(_s):

     Virasakdi Chongsuvivatwong <cvirasak@medicine.psu.ac.th>

_S_e_e _A_l_s_o:

     'recode' and 'label.var'

_E_x_a_m_p_l_e_s:

     data(Oswego)
     use(Oswego)
     des()
     rename.var("ill", "sick")
     des()
     # Note change of the 4th variable name

     rename(timesupper, time.of.supper) 
     # Note that '.var' and the quotes '"' can be omitted.
     # But not 'rename(timesupper, "time of supper")'. Why? 

     # Even shorter with 'ren'
     ren(sex, gender)
     des()

     rename.pattern("ll", "LL")  
     des()
     rename("onset", "onset_") 
     # '.pattern' can be omitted but not the quotes.
     des()

