This function is a wrapper around parallel::makePSOCKcluster() but takes
care of configuring rbmi to be used in the sub-processes as well as loading
user defined objects and libraries and setting the seed for reproducibility.
Value
If
cluster_or_coresis1, this function will returnNULL.If
cluster_or_coresis a number greater than1, a cluster withcluster_or_corescores is returned.If
cluster_or_coresis a cluster created viaparallel::makeCluster(), then this function returns it after inserting the relevantrbmiobjects into the existing cluster.
Examples
if (FALSE) { # \dontrun{
make_rbmi_cluster(5)
closeAllConnections()
VALUE <- 5
myfun <- function(x) {
x + day(VALUE)
}
make_rbmi_cluster(5, list(VALUE = VALUE, myfun = myfun), c("lubridate"))
closeAllConnections()
cl <- parallel::makeCluster(5)
make_rbmi_cluster(cl)
closeAllConnections()
} # }
