我想使用Hmisc
计算两个矩阵的相关性的p值。我在将所得的p值存储在矩阵中时遇到问题:
library("Hmisc")
x <- as.matrix(read.table("tmp01"))
y <- as.matrix(read.table("tmp02"))
P <- matrix(0, ncol(x), ncol(y))
for (i in 1:ncol(x)) {
for(j in 1:ncol(y)) {
P[i,j] <- rcorr(x[,i],y[,j])
}
}
返回此错误:
Error in P[i, j] <- rcorr(x[, i], y[, j]) :
number of items to replace is not a multiple of replacement length