Skip to content
Prev 1575 / 2152 Next

programmatically shift between %do% and %dopar% in foreach?

On Jan 8, 2013, at 11:40 AM, Max Kuhn wrote:

            
They are simply functions - you just forgot to quote it:
function (obj, ex)  

%...% are binary infix operators so if you use them as a symbol, you have to quote them.
It works, but if you want to keep the infix notation you have to use something like

`%op%` <- if (goParallel) `%dopar%` else `%do%`

otherwise for your suggestion you'd have to use the functional form:

operator(foreach(stuff), foo)

Cheers,
Simon