I have two vectors, say:
x <- c("b", "p", "t")
y <- c("a", "e", "i")
I want to get a Matrix of their possible combinations.
df <- cbind(b=c("ba", "be", "bi"), p=c("pa", "pe", "pi"), t=c("ta", "te", "ti"))
rownames(df) <- c("a", "e", "i")
I have seen Possible combinations of a matrix in R but it doesn't do the trick here.
Also I have tried CJ(x,y)
with data.table
,
but still I would need further steps to manipulate
the data.
Is there a more simple solution to this?