Not sure what this operation is called, and Google did not help.
Say I have two simple dataframes like this:
df1 <- data.frame(factor1 = c("a", "b", "c"))
df2 <- data.frame(factor2 = c("x", "y", "z"))
> df1
factor1
1 a
2 b
3 c
> df2
factor2
1 x
2 y
3 z
How can I get a dataframe formatted like this:
factor1 factor2
1 a x
2 a y
3 a z
4 b x
5 b y
6 b z
7 c x
8 c y
9 c z
I would think that this kind of operation might involve multiplying the dataframes, but this does not work:
> df1 * df2
factor1
1 NA
2 NA
3 NA
Warning message:
In Ops.factor(left, right) : ‘*’ not meaningful for factors