This post describes how to pass packages to all clusters: Function not found in R doParallel 'foreach' - Error in { : task 1 failed - "could not find function "raster""
However, I would like to pass functions to the clusters (because I use them in the foreach-loop), that are not part of an R-package. How can I do this?
Edit: My only idea was to run another foreach-loop from 1:#cluster before the actual foreach-loop and define the function in each cluster. But this is a) not very elegant and b) it doesn't work (function can still not be found)