set functions
Jonathan Rougier
J.C.Rougier@durham.ac.uk
Tue, 4 Jan 2000 16:59:45 +0000 (GMT)
On 4 Jan 2000, Peter Dalgaard BSA wrote:
> Watch:
>
> > x<-1:50000
> > y<-x[order(runif(50000))]
> > "equiv2" <- function(x, y) all(c(match(x, y, 0)>0, match(y, x, 0)>0))
> > equiv<-function(x,y)
> + length(x<-unique(x))==length(y<-unique(y)) &&
> + all(sort(x)==sort(y))
> > system.time(equiv2(x,y))
> [1] 3.10 0.02 3.00 0.00 0.00
> > system.time(equiv(x,y))
> [1] 0.77 0.00 1.00 0.00 0.00
Yup -- that's much quicker! To re-ask the original question, would it be
reasonable to include such a function along with the other set functions?
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._