dot-mapply_custom: Custom mapply Function for Parallel Processing

.mapply_customR Documentation

Custom mapply Function for Parallel Processing

Description

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'.

Usage

.mapply_custom(
  cl,
  FUN,
  ...,
  MoreArgs = NULL,
  SIMPLIFY = TRUE,
  USE.NAMES = TRUE
)

Arguments

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'.

Details

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.

Value

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'.

Author(s)

Marzia Angela Cremona & Francesca Chiaromonte


funMoDisco documentation built on April 16, 2025, 1:10 a.m.