attributes               package:base               R Documentation

_O_b_j_e_c_t _A_t_t_r_i_b_u_t_e _L_i_s_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     These functions access an object's attribute list. The first form
     above returns the an object's attribute list. The assignment forms
     make the list on the right-hand side of the assignment the
     object's attribute list (if appropriate).

_U_s_a_g_e:

     attributes(obj)
     attributes(obj) <- value
     mostattributes(obj) <- value

_A_r_g_u_m_e_n_t_s:

     obj: an object

   value: an appropriate attribute list, or 'NULL'.

_D_e_t_a_i_l_s:

     The 'mostattributes' assignment takes special care for the 'dim',
     'names' and 'dimnames' attributes, and assigns them only when that
     is valid whereas as 'attributes' assignment would give an error in
     that case.

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

_S_e_e _A_l_s_o:

     'attr'.

_E_x_a_m_p_l_e_s:

     x <- cbind(a=1:3, pi=pi) # simple matrix w/ dimnames
     str(attributes(x))

     ## strip an object's attributes:
     attributes(x) <- NULL
     x # now just a vector of length 6

     mostattributes(x) <- list(mycomment = "really special", dim = 3:2,
        dimnames = list(LETTERS[1:3], letters[1:5]), names = paste(1:6))
     x # dim(), but not {dim}names

