Re: Bug in inequalities involving ordered factors (PR#232)

About this list Date view Thread view Subject view Author view Other groups

Subject: Re: Bug in inequalities involving ordered factors (PR#232)
From: Ross Ihaka (ihaka@stat.auckland.ac.nz)
Date: Mon 26 Jul 1999 - 14:34:33 EST


Message-Id: <199907260434.QAA20417@stat1.stat.auckland.ac.nz>

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b25 : Tue 04 Jan 2000 - 14:16:06 EST