On Windows: if you use %>% inside a %dopar% loop, you have to add a reference to load package dplyr
(or magrittr
, which dplyr
loads).
Example:
plots <- foreach(myInput=iterators::iter(plotCount), .packages=c("RODBC", "dplyr")) %dopar%
{
return(getPlot(myInput))
}
If you omit the .packages
command, and use %do%
instead to make it all run in a single process, then works fine. The reason is that it all runs in one process, so it doesn't need to specifically load new packages.