factorCombinations {LinRegInteractive} | R Documentation |
Combine Levels of Different Factors to Groups
Description
All levels of the factors from a data.frame
provided are combined, each combination of factor levels is referred to as group.
Usage
factorCombinations(X, factor.sep = "|", level.sep = ".", count=TRUE)
Arguments
X |
A |
factor.sep |
Character by which the factor-factor level combinations are separated in the group names. |
level.sep |
Character by which the level names are separated from the corresponding factor names in the group names. |
count |
Should the occurences of the different groups in the |
Value
A list with the following components:
combinations |
A data frame containing every combination of factor levels (groups) for the factors provided. |
names |
A character vector with the names of the groups. Factor-factor level combinations are separated by |
counts |
If |
Note
Function is mainly for internal use in LinRegInteractive but may be useful for other purposes as well.
Examples
# multiple factors
data("CO2")
print(factorCombinations(CO2))
# single factor
data("chickwts")
print(factorCombinations(chickwts))