parallelize: Parallelize the evaluation of an expression

Description Usage Arguments Details Value

View source: R/util.R

Description

A convenient wrapper around the parallel processing backend from the doParallel package. Simply pass in the expression you'd like to be run in parallel and the result will be returned. Of course, this only helps if the code in 'expr“ is written to take advantage of a parallel backend; good examples of this are training models with 'caret::train“ or custom code making use of the 'parApply' family of functions.

Usage

1
parallelize(expr, num_cores = NULL, run_time = TRUE, ...)

Arguments

expr

An expression to be evaluated.

num_cores

The number of cores to parallelize across. By default the number of available cores minus one (i.e., 'parallel::detectCores() - 1') is used.

run_time

Should the time taken to run 'expr' be printed?

...

Additional arguments to be passed to [run_time()]

Details

Once the code has evaluated successfully or crashed the CPU cluster is shut down, ensuring you don't keep requesting additional resources without freeing any up.

Value

The result of evaluating 'expr'


lukerobert/luketools documentation built on Jan. 24, 2020, 2:15 a.m.