[Rcpp-devel] Short blog post on loop speed in R

Dirk Eddelbuettel edd at debian.org
Sun Jun 19 20:32:32 CEST 2011

On 19 June 2011 at 13:20, Douglas Bates wrote:
| Interesting post, Christian.  It turns out that the apply family can
| get better performance than the explicit loop but, as you have seen,
| no using aaply.  The choices in this case are sapply or, slightly
| faster, vapply from the base package.  I also tried using cmpfun from
| the compiler package but vapply is already very tight so  compiling
| that call doesn't change the timing.
| As for the use of Rcpp, the STL containers and algorithms can be
| exploited to an even greater extent.  If you are willing to jump
| through the hoops of defining a struct that inherits from
| std::binary_function then you can shorten the Rcpp-based code
| considerably.  See the enclosed.

Now we're talking!  Very nice post by Christian, and and a very impressive
follow-up by Doug. Keep it coming, guys


Gauss once played himself in a zero-sum game and won $50.
                      -- #11 at http://www.gaussfacts.com

More information about the Rcpp-devel mailing list