Hmisc (version 2.0-3)

interaction: Compute the Interaction of Several Factors

Description

This is a replacement for the builtin function interaction that adds the parameters sep and left.

Usage

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

Arguments

...
the arguments to interaction can be either a data frame containing all the factors to be used all the individual factors. It will not understand a combination of factors and designs as arguments; you have to pick one form or the other.
drop
if TRUE the levels of the new factor not represented in the data are dropped.
sep
the separator in creating the level descriptors.
left
set to TRUE to left-justify factor levels when constructing label strings

Value

  • a new factor, whose levels are all possible combinations of the factors supplied as arguments. If drop =TRUE, only the levels represented in the new factor are retained.

Details

This is a slight modification of the S-supplied function. The sep argument has been added, a sort step has been added to properly sort the levels of the created variable, and the left parameter is added.

Examples

Run this code
Temp <- c(160, 180, 160, 180, 160, 180, 160, 180)
Conc <- c(20, 20, 40, 40, 20, 20, 40, 40)
interaction(Temp, Conc)

Run the code above in your browser using DataCamp Workspace