Construct a product of factors.

cross(..., sep = ":", drop.unused.levels = FALSE)

Arguments

...

factors to be crossed.

sep

separator between levels

drop.unused.levels

should levels that do not appear in cross product be dropped?

Value

a factor

Examples

x <- letters[1:3]
y <- c(1,2,1,1,3,1,3)
cross(x, y)
#> [1] a:1 b:2 c:1 a:1 b:3 c:1 a:3
#> Levels: a:1 a:2 a:3 b:1 b:2 b:3 c:1 c:2 c:3
cross(x, y, drop.unused.levels=TRUE)
#> [1] a:1 b:2 c:1 a:1 b:3 c:1 a:3
#> Levels: a:1 a:3 b:2 b:3 c:1