Learn R Programming

berryFunctions (version 1.21.2)

par_sapply: cross-platform parallel processing with progbar

Description

Call pbapply::pbsapply with nc default at number of cores available. Also, this works on Windows directly.

Usage

par_sapply(
  X,
  FUN,
  nc = NULL,
  pb = TRUE,
  simplify = TRUE,
  export_objects = NULL,
  ...
)

Arguments

X

vector / list of values

FUN

function to be executed with each element of X.

nc

Integer: number of cores to be used in parallel. DEFAULT: NULL (available cores)

pb

Show progress bar with remaining time and at the end runtime? DEFAULT: TRUE

simplify

Simplify output to vector/matrix if possible? DEFAULT: TRUE

export_objects

For windows: Objects needed in FUN. DEFAULT: NULL

Further arguments passed to FUN or pbapply::pbsapply

Value

vector/matrix, list if simplify=FALSE

See Also

pbapply::pbsapply, sapply, parallelCode

Examples

Run this code
# NOT RUN {
 # Suppressed on CRAN checks as this is time-consuming
fun <- function(x) mean(rnorm(1e7))
pbapply::pbsapply(1:20, fun)
       par_sapply(1:20, fun)
          #sapply(1:20, fun)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab