From p.dalgaard at biostat.ku.dk  Wed Jan 21 01:01:00 2004
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Wed Jan 21 00:59:06 2004
Subject: [Rd]  cor( x, y ,
	method = "spearman" ) incorrect if any( is.na(c( x, y (PR#6448)
In-Reply-To: <20040120232032.3935F10539@slim.kubism.ku.dk>
References: <20040120232032.3935F10539@slim.kubism.ku.dk>
Message-ID: <x2d69ecgqr.fsf@biostat.ku.dk>

cberry@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@biostat.ku.dk)             FAX: (+45) 35327907


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