[R] %in% in R?

Peter Malewski malewski.peter at mh-hannover.de
Mon Jun 10 16:33:11 CEST 2002


On Mon, Jun 10, 2002 at 04:02:29PM +0200, Peter Dalgaard BSA wrote:
> What does it do in Hmisc?

almost the same as in "base":

> get("%in%")
function (x, table) 
match(x, table, nomatch = 0) > 0
> library(Hmisc)
*** output flushed ***
> get("%in%")
function (a, b) 
{
    if (is.factor(a) & is.numeric(b)) {
        warning("a is factor, b is numeric.  Assuming b is coded factor values")
        a <- oldUnclass(a)
    }
    else if (is.numeric(a) && is.factor(b)) {
        warning("a is numeric, b is factor.  Assuming a is coded factor values")
        b <- oldUnclass(b)
    }
    match(a, b, nomatch = 0) > 0
}
> oldUnclass
.Primitive("unclass")


PM
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list