setNames                package:stats                R Documentation

_S_e_t _t_h_e _N_a_m_e_s _i_n _a_n _O_b_j_e_c_t

_D_e_s_c_r_i_p_t_i_o_n:

     This is a convenience function that sets the names on an object
     and returns the object.  It is most useful at the end of a
     function definition where one is creating the object to be
     returned and would prefer not to store it under a name just so the
     names can be assigned.

_U_s_a_g_e:

     setNames(object, nm)

_A_r_g_u_m_e_n_t_s:

  object: an object for which a 'names' attribute will be meaningful 

      nm: a character vector of names to assign to the object

_V_a_l_u_e:

     An object of the same sort as 'object' with the new names
     assigned.

_A_u_t_h_o_r(_s):

     Douglas M. Bates and Saikat DebRoy

_S_e_e _A_l_s_o:

     'clearNames'

_E_x_a_m_p_l_e_s:

     setNames( 1:3, c("foo", "bar", "baz") )
     # this is just a short form of
     tmp <- 1:3
     names(tmp) <-  c("foo", "bar", "baz")
     tmp

