[R] na.rm problem
uhkeller at web.de
Tue Aug 1 13:38:38 CEST 2006
Like the error message tells you, cor does not have an argument "na.rm".
use="complete" already does what you want, namely casewise deletion of
However, this will not work with vectors of unequal length (how is R to
determine which observations in x correspond to those in y?). What you
could do is create a copy of y that has the same length as x but is
"padded" with NAs (missing values) using something like:
y.NA<-c(rep(NA, length(x) - length(y)), y)
Then you can compute the correlation:
cor(x, y.NA, use="complete")
sonal at deepfoo.com wrote:
> i am a new member.
> i am using R in finding correlation between two variables of unequal length.
> when i use
> where x has observations from 1928 to 2006 & y has observations from 1950 to
> 2006. I used na.rm=T to use the "complete observations". So missing values
> should be handled by casewise deletion. But it gives me error
> Error in cov(close, close1, na.rm = T, use = "complete") :
> unused argument(s) (na.rm ...)
> Please help me with this as I am new to R.
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help