(This article was originally published at Stat Bandit, and syndicated at StatsBlogs.)
I’m starting to incorporate more Rcpp in my R work, and so decided to spend some time exploring the Rcpp Gallery. One example by John Merrill caught my eye. He provides a C++ solution to transforming an list of lists into a data frame, and shows impressive speed savings compared to as.data.frame.
This got me thinking about how I do this operation currently. I tend to rely on the do.call method. To mimic the example in the Rcpp example:
a <- replicate(250, 1:100, simplify=FALSE) b <- do.call(cbind, a)
For fairness, I should get a data frame rather than a matrix, so for my comparisons, I do convert b into a data frame. I follow the original coding in the example, adding my method above into the mix. Comparing times:
res <- benchmark(as.data.frame(a),
CheapDataFrameBuilder(a),
as.data.frame(do.call(cbind, a)),
order="relative", replications=500)
res[,1:4]
The results were quite interesting to me 
Please comment on the article here: Stat Bandit
