Learn R Programming

BBmisc (version 1.2-200)

parallelMap: Maps a function over lists or vectors in parallel.

Description

Use the parallelization mode and the other options set in parallelStart. For parallel/multicore mclapply is used, for snowfall sfClusterApplyLB.

Usage

parallelMap(fun, ..., more.args = list(),
    simplify = FALSE, use.names = FALSE,
    level = as.character(NA))

Arguments

fun
[function] Function to map over ....
...
[any] Arguments to vectorize over (list or vector).
more.args
[list] A list of other arguments passed to fun. Default is empty list.
simplify
[logical(1)] Should the result be simplified? See sapply. Default is FALSE.
use.names
[logical(1)] Should result be named by first vector if that is of class character or integer? Default is FALSE.
level
[character(1)] The call is only parallelized if the same level is specified in parallelStart or this argument is NA. Default is NA.

Value

  • Result.

Details

Large objects should be separately exported via parallelExport, they can be retrieved in slave code via parallelGetExported.

Note that there is a bug in mclapply of parallel because exceptions raised during slave calls are not corretly converted to try-errror objects (as claimed in the documentation) but instead a warning is generated. Because of this, parallelMap does not generate an exception in this case either.

Examples

Run this code
parallelStart()
parallelMap(identity, 1:2)
parallelStop()

Run the code above in your browser using DataLab