我有两个双向表
male = as.table(matrix(c(60, 100, 20, 50), ncol=2))
colnames(male) = c("success", "failure")
rownames(male) = c("treat1", "treat2")
female = as.table(matrix(c(40, 10, 80, 30), ncol=2))
colnames(female) = c("success", "failure")
rownames(female) = c("treat1", "treat2")
如何创建一个三向表,命名为“三向”,这样我就可以使用调用“男性”
threeway[,,1]
并使用调用女性
threeway[,,2]
最佳答案
像这样使用abind
:
require(abind)
a<-abind(male,female,rev.along=0,make.names=T)
> a[,,1]
success failure
treat1 60 20
treat2 100 50
> a[,,2]
success failure
treat1 40 80
treat2 10 30
关于r - 如何在r中从两个双向表创建一个三向表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21872134/