« Help change the world with Data Science | Main | The R Journal: June 2011 »

June 23, 2011

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a010534b1db25970b01538f63930b970b

Listed below are links to weblogs that reference Speed up R "for" loops 50x with Rcpp:

Comments

Feed You can follow this conversation by subscribing to the comment feed for this post.

Wow, this is great!

Christian also mentioned this on the Rcpp-devel mailing list and I replied with a collection of alternatives. If you want to stay in pure R code you can use sapply or, even better, vapply to out-perform the loop. When using Rcpp it is worthwhile employing the STL algorithms when possible and I posted a version doing so.

The wonderful thing about Rcpp is that it is very close to programming in R at times and definitely much easier than programming in C with the R API. In particular all the PROTECT/UNPROTECT gymnastics are taken care of by the constructors and destructors of objects.

I sent David a copy of my posting by email.

Thanks for the comments, Doug. To everyone else, you can find Doug's alternatives in the Rcpp-devel archives.

The comments to this entry are closed.


R for the Enterprise

Got comments or suggestions for the blog editor?
Email David Smith.
Follow revodavid on Twitter Follow David on Twitter: @revodavid

Search Revolutions Blog