length                 package:base                 R Documentation

_L_e_n_g_t_h _o_f _a _V_e_c_t_o_r _o_r _L_i_s_t

_D_e_s_c_r_i_p_t_i_o_n:

     Get or set the length of vectors (including lists).

_U_s_a_g_e:

     length(x)
     length(x) <- n

_A_r_g_u_m_e_n_t_s:

       x: a vector or list.

       n: an integer.

_D_e_t_a_i_l_s:

     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'.

_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

