length                 package:base                 R Documentation

_L_e_n_g_t_h _o_f _a_n _O_b_j_e_c_t

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

     Get or set the length of vectors (including lists) and factors,
     and of any other R object for which a method has been defined.

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

     length(x)
     length(x) <- value

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

       x: a vector or list or factor.

   value: an integer.

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

     Both functions are generic: you can write methods to handle
     specific classes of objects, see InternalMethods.

     The replacement form can be used to reset the length of a vector. 
     If a vector is shortened, extra values are discarded and when a
     vector is lengthened, it is padded out to its new length with
     'NA's.

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

     The length of 'x' as an 'integer' of length 1, if 'x' is (or can
     be coerced to) a vector or list.  Otherwise, 'length' returns
     'NA'.

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

     'nchar' for counting the number of characters in character
     vectors.

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

     length(diag(4))# = 16 (4 x 4)
     length(options())# 12 or more
     length(y ~ x1 + x2 + x3)# 3
     length(expression(x, {y <- x^2; y+2}, x^y)) # 3

