Hi,
I'm confused about what the cor function is producing. I have two data
frames: pat and att. Each has 417 rows with missing data. The first,
pat, has 4 columns; att has 30. I want the correlations between each
column of pat with each column of att. My results should be a 30 by 4
matrix. I used at first
t(cor(pat, att, na.method = "omit"))
and got my 30X4 matrix. The first cell, which should be for the
correlation between pat[, 1] and att[, 1] is -0.24399252 But then, just
for a check, I did cor(pat[, 1], att[, 1], na.method = "omit") and got a
different answer! I got 0.001174417. What's going on??? According to
the Help file, the answer for my first statement with the transpose
should be "a matrix such that the [i,j] element is the covariance
(correlation) of x[,i] and either y[,j] or x[,j]. " So the [1,1] answer
should be the correlation between pat[, 1] and att[, 1] - but it's not.
What am I missing?? Am I just not seeing the obvious?? I'm using S+8.0
on a Vista machine.
Thanks,
Walt
--
________________________
Walter R. Paczkowski, Ph.D.
Data Analytics Corp.
44 Hamilton Lane
Plainsboro, NJ 08536
________________________
(V) 609-936-8999
(F) 609-936-3733
dataanalytics@earthlink.net
www.dataanalyticscorp.com
|