Cor.test()
takes vectors x
and y
as arguments, but I have an entire matrix of data that I want to test, pairwise. Cor()
t
Probably the easiest way is to use the rcorr()
from Hmisc. It will only take a matrix, so use rcorr(as.matrix(x))
if your data is in a data.frame. It will return you a list with: 1) matrix of r pairwise, 2) matrix of pairwise n, 3) matrix of p values for the r's. It automatically ignores missing data.
Ideally, a function of this kind should take data.frames too and also output confidence intervals in line with the 'New Statistics'.