Call a function with a vectorized input in parallel
Call a function with a vectorized input in parallel, where the function is computationally intensive.
A function, or a text string with the name of the function, whose first argument is a vector and returns a corresponding vector
A vector of values that is the first argument to
The number of parallel jobs to spawn using
If a numeric value is provided,
Additional named arguments for
This function is a parallelized wrapper for
do.call designed for the case where
computationally intensive. Each element of
x is evaluated
independently of the other elements of
fun(c(x1,x2)) must be equivalent
c(fun(x1), fun(x2)) in order for
doCallParallel to work properly.
The same result that would be had by calling
fun(x, ...), except calculated in parallel
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# Get a vector of x's x <- rnorm(18, mean = 2, sd = 2) # 2 cores y1 <- doCallParallel("pnorm", x, mean = 2, sd = 2, njobs = 2) # 2 cores and randomization y2 <- doCallParallel(pnorm, x, mean = 2, sd = 2, njobs = 2, random.seed = 1) # Without using doCallParallel() y3 <- pnorm(x, mean = 2, sd = 2) # Comparisons identical(y1, y2) identical(y1, y3)
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.