maechler@stat.math.ethz.ch
2000-Nov-21 15:15 UTC
[Rd] match() is not correct for "close numerics" (PR#741)
(thank to David James <dj@research.bell-labs.com> ) This is for R versions <= 1.1.1 and also R-devel as of yesterday.. > pi0 <- pi + 2*.Machine$double.eps > pi != pi0 [1] TRUE > ## but > match(c(1,pi,pi0), pi) [1] NA 1 1 The explanation is > match function(x, table, nomatch=NA) .Internal(match(as.character(x), as.character(table), nomatch)) and using > match <- function(x, table, nomatch=NA) .Internal(match(x, table, nomatch)) would solve the above problem *but* gives new ones: e.g., factor() has to be modified ! Martin Maechler <maechler@stat.math.ethz.ch> http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO D10 Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 <>< -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._