set functions

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
04 Jan 2000 17:16:48 +0100


Jonathan Rougier <J.C.Rougier@durham.ac.uk> writes:

> I wonder if we might also include an "equiv" function along with the other
> set functions (ie "union", "intersect", etc), perhaps along the lines of
> 
> "equiv" <- function(x, y) all(c(match(x, y, 0)>0, match(y, x, 0)>0))
> 
> (which I think might be the quickest implementation).  I use this type of
> function quite frequently: is there some reason why it is not in the base?

length(setdiff(x,y))==0 appears to be about twice as fast....

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._