| interaction {base} | R Documentation |
Compute Factor Interactions
Description
interaction computes a factor which represents the interaction
of the given factors. The result of interaction is always unordered.
Usage
interaction(..., drop = FALSE, sep = ".")
Arguments
... |
the factors for which interaction is to be computed, or a single list giving those factors. |
drop |
if |
sep |
string to construct the new level labels by joining the constituent ones. |
Value
A factor which represents the interaction of the given factors.
The levels are labelled as the levels of the individual factors joined
by sep, i.e. . by default.
References
Chambers, J. M. and Hastie, T. J. (1992) Statistical Models in S. Wadsworth \& Brooks/Cole.
See Also
factor; : where f:g is the same as
interaction(f,g, sep=":") when f and g are factors.
Examples
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 = ":")