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, exact = FALSE)
     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.

   exact: logical: should 'which' be matched exactly?

   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 (unless 'exact = TRUE') a
     unique partial match. (Setting
     'options(warnPartialMatchAttr=TRUE)' causes partial matches to
     give warnings.)

     The replacement function only uses exact matches.

     Note that some attributes (namely 'class', 'comment', 'dim',
     'dimnames', 'names', 'row.names' and 'tsp') are treated specially
     and have restrictions on the values which can be set. (Note that
     this is not true of 'levels' which should be set for factors via
     the 'levels' replacement function.)

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

     These functions are primitive, so argument names are ignored.

_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)

