
70 CHAPTER 3. SCHEDULING
The package has the user set up a for loop, as in serial code, but then use
the foreach() function instead of for(). One must also make one more
small change, adding an operator, %dopar%, but that’s all the user must
do to parallelize his/her serial code.
Thus foreach has a very appealing simplicity. However, in some cases, this
simplicity can mask major opportunities for achieving speedup, as will be
seen in the example in the next section.
3.10.1 Example: Mutual Outlinks Problem
Here is foreach code for the mutual outlinks problem.
mutoutfe <− function ( l i n k s ) {
require ( f o r e a c h )
nr <− nrow( l i n k s )
nc <− nc