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 = ".", lex.order = FALSE) _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. lex.order: logical indicating if the order of factor concatenation should be lexically ordered. _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' which is '.' by default. By default, when 'lex.order = FALSE', 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 (which you can get by 'lex.order = TRUE'), 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, labels = c("ctrl", "treat")) s <- gl(2, 1, 8, labels = c("M", "F")) interaction(a, b) interaction(a, b, s, sep = ":") stopifnot(identical(a:s, interaction(a, s, sep = ":", lex.order = TRUE)), identical(a:s:b, interaction(a, s, b, sep = ":", lex.order = TRUE)))