mcpmap | R Documentation |
This function applies a given function over a list of parameters in parallel using multiple cores.
mcpmap(
lists,
func,
num_cores = parallel::detectCores() - 1,
show_progress = TRUE
)
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. |
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.
A list of results from applying the function over the parameters.
params <- list(a = 1:3, b = 4:6)
mcpmap(params, function(a, b) a + b, num_cores = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.