[Rd] cor( x, y , method = "spearman" ) incorrect if any( is.na(c( x, y (PR#6448)

Peter Dalgaard p.dalgaard at biostat.ku.dk
Wed Jan 21 01:01:00 MET 2004


cberry at tajo.ucsd.edu writes:

> I think this would fix cor( ), but have not looked at the C-code for
> additional gotcha's:
> 
>     if (method != "pearson") {
>         Rank <- function(u) if (is.matrix(u)) 
>             apply(u, 2, rank)
>         else rank(u)
> +       x.na <- is.na(x)
>         x <- Rank(x)
> +       is.na( x ) <- x.na
>         if (!is.null(y)) {
> +           y.na <- is.na(y)
>             y <- Rank(y)
> +           is.na(y) <- y.na
>         }
>     }

That one got fixed a while back for r-devel, by using na.last="keep"
in the apply call, which is effectively the same fix. Looks like it
was never filed in r-bugs.

-- 
   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