0

I am currently developing an R package and would like to make use of parallelization with the package snowfall. I'd like to call a function (actually an Rcpp wrapper if this matters) from the package itself, so the function is currently not floating around in the environment.

sfInit(parallel=TRUE,cpus=Cpu)
sfExport("RcppFunction")
sfLapply(1:N,function(cc) RccpFunction(args))
sfStop()

Anytime I try to do this I get the following error message:

Error in sfExport("RcppFunction") : 
Unknown/unfound variable RcppFunction in export. (local=TRUE)

I already tried some tutorials and online handbook, but did not found yet the solution how to export any function to snowfall within a package. As far as I see it doesn't really have to do that this particular function is an RcppFunction. I hope someone can help! Thanks in advance!

PS: I already found this post, but I cannot export my own package to snowfall - at least this doesn't make sense to me.

Louki
  • 215
  • 1
  • 12
  • Try with `future_lapply(1:N, function(cc) RccpFunction(args))` of the [future.apply](https://cran.r-project.org/web/packages/future.apply) - it takes care of globals and packages automagically. – HenrikB Feb 23 '20 at 00:39
  • Re: "... I cannot export my own package to snowfall - at least this doesn't make sense to me": you're not really _exporting_ a package, you're asking for a package to be loaded/attached on the workers - that part makes sense because the workers need that package. – HenrikB Feb 23 '20 at 00:44

0 Answers0