parpbsapply {eRTG3D} | R Documentation |
Parallel sapply with progressbar
Description
Function detects the operating system and chooses the approximate kind of process for parallelizing the task: Windows: PSOCKCluster, Unix: Forking.
Usage
parpbsapply(
X,
FUN,
packages = NULL,
export = NULL,
envir = environment(),
nNodes = parallel::detectCores() - 1
)
Arguments
X |
a vector (atomic or list) or an expression object. Other objects (including classed objects) will be coerced by base::as.list. |
FUN |
function, the function to be applied to each element of X |
packages |
character vector, Only relevant for Windows: the packages needed in the function provided, eg. c("MASS", "data.table") |
export |
character vector, Only relevant for Windows: the varibales needed in the function provided, eg. c("df", "vec") |
envir |
environment, Only relevant for Windows: Environment from which the variables should be exported from |
nNodes |
numeric, Number of processes to start (unix: best to fit with the available Cores) |
Value
A vector with the results.
Examples
square <- function(x) {
x * x
}
s <- parpbsapply(X = 1:1000, FUN = square, export = c("square"), nNodes = 2)