Skip to content
Prev 256429 / 398506 Next

Odp: In need of help with correlations

Hi


r-help-bounces at r-project.org napsal dne 09.04.2011 19:24:38:
somewhat
think
to
430
top
help
that
work).
matrix
and
understand.

In cor.test help page it is said

x, y: numeric vectors of data values.  ?x? and ?y? must have the
          same length.

however your data[,2:30] is most probably data frame, see

str(data[,2:20])

To be able to do cor.test  you need to do cor.test like

cor.test(data[,2], data[,3])

or to do it in some cycle (untested)
result <- matrix(NA, 20,20)

for( i in 2:20) {
for(j in i+1:20) {

result[i,j] <- cor.test(data[,i], data[,j])
}}

But most probably there are other ways.

Regards
Petr
doing
"as.data.frame(t(data))"
analysis
error
over
and
http://www.R-project.org/posting-guide.html