Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Exegetic Analytics extols the wonders of foreach package for iterative operations that go beyond the standard “for” loop in R. For example, here's a neat (if not optimally efficient) construct using filters to calculate the primes less than 100:

foreach(n = 1:100, .combine = c) %:% when (isPrime(n)) %do% n

The open-source team at Revolution Analytics created the foreach package with parellelization in mind, and the tutorial goes on to use the doMC and doSNOW packages to speed up the foreach-based loops by running the iterations in parallel on a cluster. You can find the code used to do so, and benchmarks of the results, at the blog post linked below.

Exegetic Analytics: The Wonders of foreach