nlevels                 package:base                 R Documentation

_T_h_e _N_u_m_b_e_r _o_f _L_e_v_e_l_s _o_f _a _F_a_c_t_o_r

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

     Return the number of levels which its argument has.

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

     nlevels(x)

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

       x: an object, usually a factor.

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

     This is usually applied to a factor, but other objects can have
     levels.

     The actual factor levels (if they exist) can be obtained with the
     'levels' function.

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

     The length of 'levels(x)', which is zero if 'x' has no levels.

_S_e_e _A_l_s_o:

     'levels', 'factor'.

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

     nlevels(gl(3,7)) # = 3

