【发布时间】:2019-07-08 17:18:10
【问题描述】:
我有两个向量,比如说:
x <- c("b", "p", "t")
y <- c("a", "e", "i")
我想得到它们可能组合的矩阵。
df <- cbind(b=c("ba", "be", "bi"), p=c("pa", "pe", "pi"), t=c("ta", "te", "ti"))
rownames(df) <- c("a", "e", "i")
我见过Possible combinations of a matrix in R,但在这里不起作用。
我也试过CJ(x,y)和data.table,
但我仍然需要进一步的步骤来操纵
数据。
有没有更简单的解决方案?
【问题讨论】:
标签: r combinations