Relevel                 package:Epi                 R Documentation

_R_e_o_r_d_e_r _a_n_d _c_o_m_b_i_n_e _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:

     The levels of a factor are re-ordered so that the levels specified
     by 'ref' is first and the others are moved down. This is useful
     for 'contr.treatment' contrasts which take the first level as the
     reference. Levels may also be combined.

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

     Relevel(f, ref, first = TRUE, collapse="+" )

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

       f: An unordered factor

     ref: The names or numbers of levels to be the first. If 'ref' is a
          list, factor levels mentioned in each list element are
          combined. If the list is named the names are used as new
          factor levels.

   first: Should the levels mentioned in ref come before those not?

collapse: String used when collapsing factor levels.

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

     An unordered factor.

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

     ff <- factor( sample( letters[1:5], 100, replace=TRUE ) )
     table( ff, Relevel( ff, list( AB=1:2, "Dee"=4, c(3,5) ) ) )
     table( ff, rr=Relevel( ff, list( 5:4, Z=c("c","a") ), coll="-und-", first=FALSE ) )

