I have three columns and I would like to interact them to form a new data.table that includes all the possible combinations.
col1 = c(1,2,3,4)
col2= c(a,b)
col3 = c(x,y)
I would like the resulting table to look like:
| col1 | col2 | col3 |
-----------------------
| 1 | a | x |
| 1 | a | y |
| 1 | b | x |
| 1 | b | y |
| 2 | a | x |
....
and so on.
I can combine 2 of the columns using the merge command:
table1 = data.table(merge(unique(col1),unique(col2)))
But it doesnt work for three. Is this possible? Man thanks