I'm working on an R package, and I need to run a function myfun
on a cluster using parallel::parLapply
. myfun
calls several additional functions from my package, which in turn call more functions, some of which have multiple methods... so passing all of the functions and methods to the cluster explicitly by name is very cumbersome.
The standard advice, as I understand it, is to run
parallel::clusterEvalQ({library("my_package")})
. But the call to library("my_package")
is apparently anathema to R-CMD-check. And I have reason to believe that my-package:::function
won't fly on CRAN either.
What is the standard approach here? Do I need to export every single relevant function and method by name?
parallel
? – Sinh Nguyen