Description Usage Arguments Details Value Author(s) See Also Examples
mclapply
is a parallelized version of lapply
,
it returns a list of the same length as X
, each element of
which is the result of applying FUN
to the corresponding
element of X
.
1 2 |
X |
a vector (atomic or list) or an expressions vector. Other
objects (including classed objects) will be coerced by
|
FUN |
the function to be applied to each element of |
... |
optional arguments to |
mc.preschedule |
if set to |
mc.set.seed |
if set to |
mc.silent |
if set to |
mc.cores |
The number of cores to use, i.e. how many processes will be spawned (at most) |
mc.cleanup |
if set to |
mclapply
is a parallelized version of lapply
, but there
is an important difference: mclapply
does not affect the
calling environment in any way, the only side-effect is the delivery
of the result (with the exception of a fall-back to lapply
when
there is only one core).
By default (mc.preschedule=TRUE
) the input vector/list X
is split into as many parts as there are cores (currently the values
are spread across the cores sequentially, i.e. first value to core
1, second to core 2, ... (core + 1)-th value to core 1 etc.) and
then one process is spawned to each core and the results are
collected.
Due to the parallel nature of the execution random numbers are not
sequential (in the random number sequence) as they would be in
lapply
. They are sequential for each spawned process, but not
all jobs as a whole.
In addition, each process is running the job inside try(...,
silent=TRUE)
so if error occur they will be stored as
try-error
objects in the list.
Note: the number of file descriptors is usually limited by the
operating system, so you may have trouble using more than 100 cores
or so (see ulimit -n
or similar in your OS documentation)
unless you raise the limit of permissible open file descriptors
(fork will fail with "unable to create a pipe").
A list.
Simon Urbanek
1 2 3 4 5 6 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.