mcpmap {mcstatsim}R Documentation

Parallel Map Function using pbapply::pbmapply

Description

This function applies a given function over a list of parameters in parallel using multiple cores.

Usage

mcpmap(
  lists,
  func,
  num_cores = parallel::detectCores() - 1,
  show_progress = TRUE
)

Arguments

lists

A list of lists containing the parameters for the function.

func

The function to be applied.

num_cores

The number of cores to use for parallel execution. Default is one less than the total number of available cores.

show_progress

Logical indicating whether to display the progress bar. Default is TRUE.

Details

The function ensures that all elements in the list have the same length and uses 'pbapply::pbmapply' for parallel processing. It sets the number of cores based on the operating system and then applies the function in parallel.

Value

A list of results from applying the function over the parameters.

Examples

params <- list(a = 1:3, b = 4:6)
mcpmap(params, function(a, b) a + b, num_cores = 2)

[Package mcstatsim version 0.5.0 Index]