[Rd] cor(..., method="spearman") or cor(..., method="kendall") (PR#6641)

Peter Dalgaard p.dalgaard at biostat.ku.dk
Wed Mar 3 23:45:27 MET 2004


JRitter at hhh.umn.edu writes:

> Dear R maintainers,
> 
> R is great.  Now that I have that out of the way, I believe I have
> encountered a bug, or at least an inconsistency, in how Spearman and
> Kendall rank correlations are handled.  Specifically, cor() and
> cor.test() do not produce the same answer when the data contain NAs.

We know... PR#6448 is the same thing. (The problem is that rank()
follows sort() which by default sorts NA's to the end of the sorted
vector. Thus NA's get a high rank and if both x and y have NA at the
same time, a high spearman correlation is calculated.) It is fixed in
the patched R version and also in the development sources (soon to be
1.9.0). 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907



More information about the R-devel mailing list