Here you will find daily news and tutorials about R, contributed by over 573 bloggers.
There are many ways to follow us - By e-mail:On Facebook: If you are an R blogger yourself you are invited to add your own R content feed to this site (Non-English R bloggers should add themselves- here)

In R language, the members at Revolution R provide foreach and doSNOW packages for parallel computation. these packages allow us to compute things in parallel. So, we start to install these packages.

In foreach package, you can write the codes which are run not only in parallel but also in sequence. And, these are as following.

Next, we make clusters by doSNOW package for the purpose of parallel computation. Because I have dual core machine, I specify two as the number of clusters.

Now, We are ready to compute things in parallel. It is easy for us to do that by foreach package. You only have to change “%do%” into “%dopar%”. I compared the performance of parallel comutation to single computation as following.

(I’m sorry that some terms are written in Japanese!)

You can understand the result of parallel computation is about twice as fast as single computation do !!!