From J.C.Rougier@durham.ac.uk  Thu Jan  6 09:19:33 2000
From: J.C.Rougier@durham.ac.uk (Jonathan Rougier)
Date: Thu, 6 Jan 2000 09:19:33 +0000 (GMT)
Subject: set functions
In-Reply-To: <14451.5075.867165.954414@gargle.gargle.HOWL>
Message-ID: <Pine.GSO.4.20.0001060904580.22904-100000@laplace>

Hi Martin,

> However, I think "equiv" is not specific enough (could mean "equivalence of
> arbitrary R objects").
> Wouldn't  "setequiv" or "setequal" be better ?
> 
> ((and would you provide (to R-core)  patches to
>     src/library/base/R/sets.R and src/library/base/man/sets.Rd))

I think, after all of the discussion, particularly Brian's helpful
interventions, the original function prevails, although Peter's suggested
sorting function was very instructive.

"setequal" <- function(x, y) all(c(match(x, y, 0)>0, match(y, x, 0)>0))

The help function needs the following modifications:

\alias{setequal}

\description{Performs set union, intersection, difference, equality and
membership on two vectors.}

\usage{
union(x, y)
intersect(x, y)
setdiff(x, y)
setequal(x, y)
is.element(x, y)
}

%% There appears to be an extra tab or other white space in the arguments
%% field.

\examples{
x <- sample(1:20, 10)
y <- sample(3:23, 7)
union(x, y)
intersect(x, y)
setdiff(x, y)
setequal(x, y)
is.element(y, x)
}

Cheers, Jonathan.

Jonathan Rougier                       Science Laboratories
Department of Mathematical Sciences    South Road
University of Durham                   Durham DH1 3LE

"[B]egin upon the precept ... that the things we see are to be 
 weighed in the scale with what we know"  (Meredith, 1879, The Egoist)

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


set functions
Jonathan Rougier