[R] Error in cor.default(x1, x2) : missing observations in cov/cor

Peter Dalgaard p.dalgaard at biostat.ku.dk
Wed Feb 27 22:55:49 CET 2008


Ken Spriggs wrote:
> Hello,
>
> I'm trying to do cor(x1,x2) and I get the following error:
> Error in cor.default(x1, x2) : missing observations in cov/cor
>
> A few things:
> 1.  I've used cor() many times and have never encountered this error.
> 2.  length(x1) = length(x2)
> 3.  is.numeric(x1) = is.numeric(x2) = TRUE
> 4.  which(is.na(x1))  = which(is.na(x2)) = integer(0)   {the same goes for
> is.nan()}
> 5.  I also try cor(x1,x2, use = "all.obs") and get the same error.
>
> What can be going wrong?
>
>
>   
Er, this is strange. As far as I can see, cor is not normally generic, and

 > getAnywhere("cor.default")
no object named ‘cor.default’ was found

so something is not normal. What do you get from a traceback() after the 
error, which is your cor.default, and what is the class of x1 and x2? Do 
you perchance have some special packages loaded?

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



More information about the R-help mailing list