Skip to content
Back to formatted view

Raw Message

Message-ID: <x2d69ecgqr.fsf@biostat.ku.dk>
Date: 2004-01-21T00:59:06Z
From: Peter Dalgaard
Subject: cor( x, y , method = "spearman" ) incorrect if any( is.na(c( x, y (PR#6448)
In-Reply-To: <20040120232032.3935F10539@slim.kubism.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