[R-pkg-devel] could not find function "%dopar%"

Mohammad Ali Nilforooshan m@@@n|||oroo@h@n @end|ng |rom gm@||@com
Mon Feb 25 03:26:55 CET 2019


Problem solved!
`%dopar%` <- foreach::`%dopar%`


One of my functions does parallel processing with "doParallel" and
> "foreach". "foreach" is a dependency to "doParallel". My R package keeps
> failing, because %dopar% is not recognized as a function. I tried
> %foreach::dopar%, %parallel::dopar% , %doParallel::dopar%, and
> %iterators::dopar%. It didn't help!
>
> In DESCRIPTION, I have:
>
> Suggests:
>    dpParallel (>= 1.0.14)
>
> I want it to be "suggested" rather than a dependency.
> Following is the example function. To make sure that it is working, try
> library("doParallel").
>
> myfunc = function(n) {
>    if(requireNamespace("doParallel", quietly=TRUE))
>    {
>       cl = parallel::makeCluster(2)
>       doParallel::registerDoParallel(cl)
>       Q = foreach::foreach(i=1:n, .combine='cbind') %dopar% rep(i, 5)
>       parallel::stopCluster(cl)
>       return(Q)
>    } else {
>       print("Package doParallel is required.")
>    }
> }
>
> Your help is really appreciated!
>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list