attr                  package:base                  R Documentation

_O_b_j_e_c_t _A_t_t_r_i_b_u_t_e_s

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

     Get or set specific attributes of an object.

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

     attr(x, which)
     attr(x, which) <- value

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

       x: an object whose attributes are to be accessed.

   which: a non-empty character string specifying which attribute is to
          be accessed.

   value: an object, the new value of the attribute, or 'NULL' to
          remove the attribute.

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

     These functions provide access to a single attribute of an object.
     The replacement form causes the named attribute to take the value
     specified (or create a new attribute with the value given).

     The extraction function first looks for an exact match to 'which'
     amongst the attributes of 'x', then a unique partial match.  The
     replacement function only uses exact matches.

     Note that some attributes (namely 'class', 'comment', 'dim',
     'dimnames', 'names', (from R 2.4.0) 'row.names' and 'tsp') are
     treated specially and have restrictions on the values which can be
     set.

     The extractor allows (and does not match) empty and missing values
     of 'which': the replacement function does not.

_V_a_l_u_e:

     For the extractor, the value of the attribute matched, or 'NULL'
     if no exact match is found and no or more than one partial match
     is found.

_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:

     'attributes'

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

     # create a 2 by 5 matrix
     x <- 1:10
     attr(x,"dim") <- c(2, 5)

