interaction               package:base               R Documentation

_C_o_m_p_u_t_e _F_a_c_t_o_r _I_n_t_e_r_a_c_t_i_o_n_s

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

     'interaction' computes a factor which represents the interaction
     of the given factors.  The result of 'interaction' is always
     unordered.

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

     interaction(..., drop = FALSE, sep = ".")

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

     ...: the factors for which interaction is to be computed, or a
          single list giving those factors.

    drop: if 'drop' is 'TRUE', unused factor levels are dropped from
          the result.  The default is to retain all factor levels.

     sep: string to construct the new level labels by joining the
          constituent ones.

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

     A factor which represents the interaction of the given factors.
     The levels are labelled as the levels of the individual factors
     joined by 'sep', by '.' by default.

     The levels are ordered so the level of the first factor varies
     fastest, then the second and so on.  This is the reverse of
     lexicographic ordering, and differs from ':'.  (It is done this
     way for compatibility with S.)

_R_e_f_e_r_e_n_c_e_s:

     Chambers, J. M. and Hastie, T. J. (1992) _Statistical Models in
     S_. Wadsworth & Brooks/Cole.

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

     'factor'; ':' where 'f:g' is similar to 'interaction(f, g,
     sep=":")' when 'f' and  'g' are factors.

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

     a <- gl(2, 4, 8)
     b <- gl(2, 2, 8, label = c("ctrl", "treat"))
     s <- gl(2, 1, 8, label = c("M", "F"))
     interaction(a, b)
     interaction(a, b, s, sep = ":")

