number of items to replace is not a multiple of replacement length

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

number of items to replace is not a multiple of replacement length

yueli7
Hello,

I want to calculate the correlation value of two matrix.

Thanks in advance!

> 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