.mapply_custom | R Documentation |
A wrapper function that conditionally applies either the classical 'mapply' function or 'parallel::clusterMap' based on whether a cluster object is provided. If the number of clusters is not null, it applies 'clusterMap' for parallel execution; otherwise, it defaults to the classical 'mapply'.
.mapply_custom(
cl,
FUN,
...,
MoreArgs = NULL,
SIMPLIFY = TRUE,
USE.NAMES = TRUE
)
cl |
A cluster object created by 'makeCluster'. If 'NULL', the classical 'mapply' function is used. |
FUN |
A function to apply to the arguments. |
... |
Arguments to be passed to 'FUN'. These should be vectors of equal length. |
MoreArgs |
A list of additional arguments to be passed to 'FUN'. |
SIMPLIFY |
A logical value indicating whether to simplify the result if possible. Default is 'TRUE'. |
USE.NAMES |
A logical value indicating whether to use names from the first argument. Default is 'TRUE'. |
This function is useful for switching between parallel and non-parallel execution based on the availability of a cluster, allowing for more flexible and efficient code.
A vector or list containing the results of applying the function 'FUN' to the provided arguments. The output type depends on the value of 'SIMPLIFY'.
Marzia Angela Cremona & Francesca Chiaromonte
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.