[R] A possible too old question on significant test of correlation matrix

From: Guo Wei-Wei <wwguocn_at_gmail.com>
Date: Mon 10 Jul 2006 - 15:27:53 EST

Dear all,

I'm working on a data.frame named en.data, which has n cases and m columns. I generate the correlation matrix of en.data by

> cor(en.data)

I find that there is no p-value on each correlation in the correlation matrix. I searched in the R-help mail list and found some related posts, but I didn't find direct way to solve the problem. Someone said to use cor.test() or t.test(). The problem is that cor.test() and t.test() can only apply on two vectors, not on a data.frame or a matrix.

My solution is

for (i in 1:(ncol(en.data) -1)) {

   cor.test(en.data[,i], en.data[, i+1]) }

I think it is a stupid way. Is there a direct way to do so? After all, it is a basic function to generate significant level of a correlation in a correlation matrix.

Thank you in advance!

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Jul 10 15:37:34 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 10 Jul 2006 - 20:15:00 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.