[Rd] Bug in cor function (PR#7689)

From: <cig69410_at_syd.odn.ne.jp>
Date: Sun 13 Feb 2005 - 17:08:19 EST


I can't hardly accept the result of cor function with pairwize.colplete.obs or complete.obs

insert print statements in cor function,

+     if (method != "pearson") {
  +         Rank <- function(u) if (is.matrix(u))
  +             apply(u, 2, rank, na.last = "keep")
  +         else rank(u, na.last = "keep")
  +         x <- Rank(x)
  +         print(x) # add
  +         if (!is.null(y)) {
  +             y <- Rank(y)
  +             print(y) # add
  +         }
  +     }
  +     .Internal(cor(x, y, na.method, method == "kendall"))

and, data is
> x <- c(7, 9, 8, 0, NA, NA)
> y <- c(2, 3, 4, NA, 4, 3)

and, call cor function
> cor(x, y, use="pair", method="sp")

order of x, and y are
  [1] 2 4 3 1 NA NA
  [1] 1.0 2.5 4.5 NA 4.5 2.5

alas!! and the result is
  [1] 0.4271211

oh! no!!

the result must be 0.5



R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sun Feb 13 16:15:18 2005

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:02:51 EST