powered by
Parallelize a function
parallelize_fun(x, fun, cores = 1, export_fun = NULL, verbose = TRUE)
A list of computed results.
A vector or list to apply over.
The function to be applied to each element.
The number of cores to use for parallelization with foreach::foreach. Default is 1.
1
The functions to export the function to workers.
Whether to print progress messages. Default is TRUE.
TRUE
parallelize_fun(1:3, function(x) { Sys.sleep(0.2) x^2 }) parallelize_fun(list(1, 2, 3), function(x) { Sys.sleep(0.2) x^2 }, cores = 2)
Run the code above in your browser using DataLab