[R] Help creating a correlation matrix

Robert O'Brien dinklemus_littlelog at yahoo.com
Wed May 21 00:41:05 CEST 2008


Hello all. I have 14 variables, named D2_1,
D2_2,...,D2_14 (inherited from a data set). I would
like to create a matrix of correlations, although I
would be content in just learning how to create a
proper do loop. I tried something like this:


(for i in 1:14){cor(D2_[i],D2_[i], use =
"complete.obs")}

This is wrong, of course, but I don't know how to
"tell" R to run through D2_1, D2_2,...,D2_14 giving me
the correlations for each pair. 

Any help or hints would be appreciated.

Sincerely,

Robert O'Brien



More information about the R-help mailing list