[Rd] Bug in cor function (PR#7689)
cig69410 at syd.odn.ne.jp
cig69410 at syd.odn.ne.jp
Sun Feb 13 07:08:19 CET 2005
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
More information about the R-devel
mailing list