register_parallel: Register parallel

Description Usage Arguments Examples

View source: R/register-parallel.R

Description

Register parallel in functions. Do makeCluster(), registerDoParallel() and stopCluster() when the function returns.

Usage

1

Arguments

ncores

Number of cores to use. If using only one, then this function uses foreach::registerDoSEQ().

...

Arguments passed on to makeCluster().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 

test <- function(ncores) {
  register_parallel(ncores)
  foreach(i = 1:2) %dopar% i
}

test(2)  # only inside the function
foreach(i = 1:2) %dopar% i

## End(Not run)

bigparallelr documentation built on Oct. 2, 2021, 5:08 p.m.