R 语言: number of items to replace is not a multiple of replacement length
各位大神,
想计算两个矩阵每一行的相关系数的P值。 用的是R语言。
先谢谢了!
> write.table(P,"P",sep="\t")
> x<-as.matrix(read.table("tmp01"))
> y<-as.matrix(read.table("tmp02"))
> P<-matrix(0,nrow(x),nrow(y))
> for (i in 1:nrow(x)){
+ for(j in 1:nrow(y)){
+ P[i,j]<-cor.test(x[i,],y[j,])}}
Error in P[i, j] <- cor.test(x[i, ], y[j, ]) :
number of items to replace is not a multiple of replacement length