Skip to content
Prev 626 / 2152 Next

foreach: using either %do% or %dopar% depending on condition

You could try something like this:

    > '%my%' <- if (hpc == "none") get('%do%') else get('%dopar%')

However, why not just let the user decide by either registering a parallel
backend or not?  The main purpose of the "registerDoSEQ" function is
to allow the user to say that parallel operations should be done sequentially.
The '%dopar%' function is the programmer's way to declare that the
foreach loop can be executed in parallel.  It's the user's job to declare
how the '%dopar%' should be executed.  That also simplifies the code
by not having to define and pass around yet another option to your
functions.

- Steve
On Mon, May 3, 2010 at 6:45 AM, mat <matthieu.stigler at gmail.com> wrote: