“A happy man is too satisfied with the present to dwell too much on the future.”

-Albert Einstein

TL;DR

Overview

PreciseDist relies on the Future package to process functions in parallel. Briefly, the future package attempts to unify the various parallel backends into a consistent framework for most use cases, and it’s philosophy is to put the power in the user’s hands rather than myopically hardcoding the parallel backend into the package code. Thus, the following are some code snippets to get you started, but for much more information please see the future package overview. Also, PreciseDist has never been tested on a cluster, so please file an issue at the PreciseDist issues page if you are trying this and running into difficulties you believe can be traced back to this package. We would be more than happy to try to help.

Running PreciseDist in Parallel

PreciseDist currently utilizes the foreach package for all of it’s parallelism. We chose foreach over something like the furrr package because it has some very nice options like automatic error handling, which is very useful when running data against 100+ distances in which some of the distances are bound to fail.

Here is the code to initialize a parallel backend for and PreciseDist function that has a parallel parameter:

Now the PreciseDist function will run in parallel as long as you also set parallel = TRUE as one of the function arguments. If this is still unclear, examples of using PreciseDist’s parallel framework are scattered throughout the vignettes.

Other Future backend options

The following code will achieve the same results as the above code, but it will use a different parallel backend behind the scenes. If future is giving you errors try switching the backend to one of the following before filing an issue or giving up. See the doFuture GitHub page for more information.

Future Options

Future has a host of options that can be set, but the most useful one in my experience is:

Running this when you start your R session prevents a potential “Error in getGlobalsAndPackages” by allowing an infinite size to the global variables future identifies.