[R] cor() btwn columns in two matrices - no complete element pairs

rcoder mpdotbook at gmail.com
Fri Aug 15 15:44:36 CEST 2008


Hi everyone,

I'm trying to calculate correlation coefficients between corresponding
columns in two matrices with identical dimensions but different data. The
problem is that the matrices contain NAs in different locations. I am using
the following code to try to calculate correlations between complete sets of
data:

#Code start
maxcol<-ncol(mat1)
for (i in 1:maxcol)
	{
corr_results[1,i]<-cor(mat1[,i],mat2[,i], use="complete.obs")
	}
#Code end

...but I get the following error message:

Error in cor(mat1[,i], mat2[,i], use="complete.obs") : 
  no complete element pairs

Is there something I'm not including in the 'cor' parentheses? I apologise
for not including the true original data frames.

Thanks,

rcoder
-- 
View this message in context: http://www.nabble.com/cor%28%29-btwn-columns-in-two-matrices---no-complete-element-pairs-tp18998875p18998875.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list