[R] Help creating a correlation matrix

From: Robert O'Brien <dinklemus_littlelog_at_yahoo.com>
Date: Tue, 20 May 2008 15:41:05 -0700 (PDT)


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



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 20 May 2008 - 22:47:30 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 21 May 2008 - 07:30:38 GMT.

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

list of date sections of archive