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? 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> length(setdiff(x,y))==0 appears to be about twice as fast....but isn't the same, is it?> length(setdiff(1:10, 1:15))==0[1] TRUE> "equiv" <- function(x, y) all(c(match(x, y, 0)>0, match(y, x, 0)>0)) > equiv(1:10, 1:15)[1] FALSE or isn't setdiff expected to do> setdiff(1:10, 1:15)numeric(0)> setdiff(1:15, 1:10)[1] 11 12 13 14 15 what it currently does? -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at 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 at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. _._ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._