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

June 23, 2011


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