5

I am trying to use parLapply again (now successfully used it in this context) but this time the function to parallelize contains some functions from the mc2d package (ie. deprt, ppert). I installed and loaded the package, before the parallel part of the code.

I successfully exported my variables to the cluster using cluster export,

clusterExport(C1, "variable")
...

However I tried to export the functions dpert and ppert using

clusterEvalQ(C1,dpert)

and I get the error

object C1 not found

how does it not find C1? is there another way to export R-packages functions to the cluster for parallel processing?

2 Answers 2

9

Use clusterExport for functions as well...

clusterExport(Cl,c('dpert','variable'))
Sign up to request clarification or add additional context in comments.

Comments

0

Another way I accidentally discovered is to add the name of the package to which the function belongs before the function call. E.g. instead of say syms() or group_indices() you use rlang::syms() or dplyr::group_indices() inside parLapply() (or any other parallel library function).

1 Comment

could you give a full clusterExport call example ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.