[R] Multiple output from cor.test
joseph.wakeling at webdrake.net
Tue Apr 10 12:20:08 CEST 2007
I'm trying to use cor.test across a range of values via the apply command,
c <- apply(X,1,cor.test,y)
where X is an array, giving me multiple output from cor.test. I can
access individual elements of this by e.g. c[] or c[]$estimate or
c[[n]] or whatever, but is there a way to get out the vector of all
estimates, or all p-values?
i.e. if I want to get out a vector p which is in effect,
p <- c(c[]$p.value, c[]$p.value, ..... )
can I do this without doing a for loop?
I note that I can't do something like c[[1:n]]$p.value, for example.
I have to say I don't understand the notation c[[n]] to get the n'th
estimate so if anyone could explain it I would be very happy.
More information about the R-help