On Wed, Dec 5, 2012 at 12:02 AM, arun <smartpink...@yahoo.com> wrote: > Hi, > > > p <- lapply(1:1e6, function(i)c(i, log2(i))) > > system.time(z1 <- t(sapply(p,function(x)x))) > # user system elapsed > # 2.568 0.048 2.619 > system.time(z1 <- do.call(rbind,p)) > # user system elapsed > # 4.000 0.052 4.060 > A.K.
Thanks for that Arun -- I'll have to look into why rbind is so slow. Some interesting notes: 1) On my machine t(sapply(p, function(x) x)) is about 2x faster than t(sapply(p, identity)) 2) Similarly, do.call(rbind, p) is about 4x slower than do.call(cbind, p) which all goes to show, profiling is all-important (as Bill reminds me often) and often counter-intuitive. Michael ______________________________________________ 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.