> benchmark( + all_eq = {isTRUE(all.equal.numeric(x,y))}, + dfrm = {compare<-data.frame(id<-seq(1,43e3,1),x,y); + compare$id[compare$x!=compare$y]}, + int = {(compare$x!=compare$y)}, + slf = {differences<-compare$id[compare$x!=compare$y]}, + replications=1000) test replications elapsed relative user.self sys.self 1 all_eq 1000 14.61 11.068182 12.59 0.02 2 dfrm 1000 27.08 20.515152 23.38 0.00 3 int 1000 1.32 1.000000 1.20 0.00 4 slf 1000 3.45 2.613636 2.91 0.00
Because: a) in many real cases data frame may exist, so you create it only once b) loop was "unfair" ;) c) my approach gives an information about "the indices of positions at which the vectors differ" Time of "evaluation of differences" is also mesured, not only assignment to vector. Summary: If you already got a data frame, slf method can be a few times faster. If you don't have it, and you only need to know are they differ as a whole check by all_eq. It depends on needs and stored format. W dniu 13 października 2010 00:16 użytkownik David Winsemius <dwinsem...@comcast.net> napisał: > And as a result you have chosen not to include the creation of the > data.frame inside your loop. > > David Winsemius, MD > West Hartford, CT -- Miłego dnia ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.