john.maindonald@anu.edu.au
1999-Jul-26 02:41 UTC
Bug in inequalities involving ordered factors (PR#232)
> stress.level<-rep(c("low","medium","high"),2) > ordf.stress<-ordered(stress.level, levels=c("low","medium","high")) > ordf.stress[1] low medium high low medium high Levels: low < medium < high> ordf.stress >= "medium"[1] FALSE TRUE FALSE FALSE TRUE FALSE #### Clearly the third and sixth values should be TRUE --please do not edit the information below-- Version: platform = Windows arch = x86 os = Win32 system = x86, Win32 status = status.rev = 0 major = 0 minor = 64.2 year = 1999 month = July day = 3 language = R Windows 9x 4.0 (build 1111) B Search Path: .GlobalEnv, Autoloads, package:base John Maindonald email : john.maindonald@anu.edu.au Statistical Consulting Unit, phone : (6249)3998 c/o CMA, SMS, fax : (6249)5549 John Dedman Mathematical Sciences Building Australian National University Canberra ACT 0200 Australia -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Here is a QuickFix (TM) which probably needs more careful thought. (It looks like Ops.ordered has only been partially implemented). Ops.ordered <- function (e1, e2) { nas <- is.na(e1) | is.na(e2) ord1 <- FALSE ord2 <- FALSE if (nchar(.Method[1])) { l1 <- levels(e1) ord1 <- TRUE } if (nchar(.Method[2])) { l2 <- levels(e2) ord2 <- TRUE } if (all(nchar(.Method)) && (length(l1) != length(l2) || !all(sort(l2) == sort(l1)))) stop("Level sets of factors are different") if (ord1 && ord2) { e1 <- codes(e1) e2 <- codes(e2) } else if (!ord1) { e1 <- match(e1, l2) e2 <- codes(e2) } else if (!ord2) { e2 <- match(e2, l1) e1 <- codes(e1) } value <- get(.Generic, mode = "function")(e1, e2) value[nas] <- NA value } I have committed this in the development version, but it probably needs more thought than I have time for at present. Ross -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._