Skip to content

%in% in R?

4 messages · Juan Ramon Gonzalez, Peter Dalgaard, Brian Ripley +1 more

#
Hi,

Does anyone know if exists a similar funcion to %in% from Hmisc S-plus
library in R?

Thank you

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
"Juan Ramon Gonzalez" <jrgonzalez at ico.scs.es> writes:
What does it do in Hmisc?
#
On Mon, 10 Jun 2002, Juan Ramon Gonzalez wrote:

            
As far as I know that is essentially the same as the binary operator %in%
which is part of R ... and S+6.1.

Hmisc for R is (I believe) available from Dr Harrell's site.
#
On Mon, Jun 10, 2002 at 04:02:29PM +0200, Peter Dalgaard BSA wrote:
almost the same as in "base":
function (x, table) 
match(x, table, nomatch = 0) > 0
*** output flushed ***
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
}
.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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._