Florian Prive shows off a few methods for parallelizing code in R:
Parallelize with foreach
You need to do at least two things:
-
replace
%do%by%dopar%. Basically, always use%dopar%because you can useregisterDoSEQ()is you really want to run theforeachsequentially. -
register a parallel backend using one of the packages that begin with do (such as
doParallel,doMC,doMPIand more). I will list only the two main parallel backends because there are too many of them.
Check it out. Florian spends a lot of time with foreach and doParallel, a little bit of time with flock, and mentions Microsoft R Open. H/T R-Bloggers