Extract.factor             package:base             R Documentation

_E_x_t_r_a_c_t _o_r _R_e_p_l_a_c_e _P_a_r_t_s _o_f _a _F_a_c_t_o_r

_D_e_s_c_r_i_p_t_i_o_n:

     Extract or replace subsets of factors.

_U_s_a_g_e:

     ## S3 method for class 'factor':
     x[..., drop = FALSE]
     ## S3 method for class 'factor':
     x[[i]]
     ## S3 replacement method for class 'factor':
     x[...] <- value

_A_r_g_u_m_e_n_t_s:

       x: a factor

  ..., i: a specification of indices - see 'Extract'.

    drop: logical.  If true, unused levels are dropped.

   value: character: a set of levels.  Factor values are coerced to
          character.

_D_e_t_a_i_l_s:

     When unused levels are dropped the ordering of the remaining
     levels is preserved.

     If 'value' is not in 'levels(x)', a missing value is assigned with
     a warning.

     Any 'contrasts' assigned to the factor are preserved unless
     'drop=TRUE'.

_V_a_l_u_e:

     A factor with the same set of levels as 'x' unless 'drop=TRUE'. 
     (Prior to R 2.4.0, '[[' returned the integer code.)

_S_e_e _A_l_s_o:

     'factor', 'Extract'.

_E_x_a_m_p_l_e_s:

     ## following example(factor)
     (ff <- factor(substring("statistics", 1:10, 1:10), levels=letters))
     ff[, drop=TRUE]
     factor(letters[7:10])[2:3, drop = TRUE]

