plapply: Parallel, reproducible lapply function with comfort

Description Usage Arguments Details Value See Also

View source: R/plapply.R

Description

Parallel, reproducible version of R's lapply() function. Proof of concept - for testing purposes only

Usage

1
2
3
plapply(X, FUN, ..., progress = FALSE, title = "Progress", memo = FALSE,
  resume = FALSE, eta = FALSE, time = FALSE, threads = 1,
  sameSeed = FALSE, stopOnError = TRUE, seed = NULL, simplify = FALSE)

Arguments

X

A vector or list. Any object that can be coerced by as.list.

FUN

The function to be applied to each element of X.

...

Additional arguments to FUN.

progress

A logical value or a cahracter string. If TRUE or "bar", a modern looking progress bar shows the status of the computations. Further options are "batch" and "simple" which print simpler progress bars.

title

The printed title of the progress bar.

memo

A logical value. If TRUE, FUN is transformed to memorize its output per distinct input arguments in an internal cache. If FUN is applied to the same input again, it returns the corresponding cached pre-computed output (see Details).

resume

A logical value. If TRUE, the function records the output per iteration in the folder "tmp". If you re-run the function, it will resume the computations.

eta

A logical value. If TRUE, the estimated time (and date) of availability (ETA) is printed

time

A logical value. If TRUE, the estimated and the elapsed time of the progress are printed.

threads

An integer. The number of threads, i.e. parallel processes, to employ. Caution: At the moment, only Unix based systems are supported for threads > 1 (see Details).

sameSeed

A logical value. If TRUE, the same seed is set before each iteration.

stopOnError

A logical value. If TRUE, the execution stops immediately in case of an error. Otherwise, an error object in place for the failed iteration is returned.

seed

An integer. Sets a random seed in the beginning.

simplify

A logical value. If TRUE, the resulting list will be transformed (simplified) by simplify2array().

Details

Uniform clear and clean way making computations reproducible. It does not matter, whether the computations are performed serially or parallely.

Caution:

  1. Currently, non-unix systems are restricted to threads = 1 because they do not support R's parallel mechanism (forking).

  2. Use Option memo = TRUE ONLY for functions that do NOT DRAW RANDOM NUMBERS. Otherwise, the result will be like the functions always proceeds with the same random draw.

Value

The function returns TRUE if no error occurred.

See Also

lapply, sapply, mclapply and simplify2array().


ratmaster/collateral documentation built on May 24, 2019, 6:19 p.m.