combineLevels             package:gdata             R Documentation

_C_o_m_b_i_n_e _l_e_v_e_l_s _o_f _g_i_v_e_n _f_a_c_t_o_r_s

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

     'combineLevels' combines levels of given factors and applies this
     levels to given factors. This eases the work with factors since
     all factors have the same levels.

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

     combineLevels(x, apply=TRUE, drop=FALSE)

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

       x: data.frame or list, object with factors

   apply: boolean, apply combined levels to 'x' or just return combined
          levels

    drop: boolean, drop unused levels

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

     'apply' handles the output. If 'apply=TRUE' the output is a
     modified 'x', where all factors have the same set of levels. If
     'apply=FALSE' only combined levels are returned.

_A_u_t_h_o_r(_s):

     Gregor Gorjanc

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

     'factor', 'levels', 'mapFactor'

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

     (f1 <- factor(letters[1:5]))
     (f2 <- factor(letters[3:10]))
     tmp <- list(f1, f2)
     combineLevels(tmp)
     combineLevels(tmp, apply=FALSE)

     f1[2] <- NA
     f1 <- factor(f1)
     tmp <- list(f1, f2)
     combineLevels(tmp, apply=FALSE, drop=TRUE)

