correlation with NA (was Re: [R] (no subject))

From: Sundar Dorai-Raj <sundar.dorai-raj_at_pdf.com>
Date: Thu 17 Mar 2005 - 08:59:29 EST

Brett Stansfield wrote on 3/16/2005 3:54 PM:
> Dear R
> I'm trying to do a correlation matrix for some variables I have.
> Unfortunately there are some NA entries for some of the variables
> I tried the following
>
> cor(sleep[c("logbw", "logbrw", "SlowSleep", "ParaSleep", "loglife",
> "loggest")])
>
> but it told me
> Error in cor(sleep[c("logbw", "logbrw", "SlowSleep", "ParaSleep", "loglife",
> :
> missing observations in cov/cor
>
> How can I get R to conduct a correlation matrix for this data set??
>
> brett

See ?cor. I think you want:

cor(sleep, use = "complete.obs") # or "pairwise.complete.obs"

(please read the posting guide, which would tell you to use an informative subject line and also point you to the help files)

PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

--sundar



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 Thu Mar 17 09:05:29 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:50 EST