parpblapply {eRTG3D} | R Documentation |
Parallel lapply with progressbar
Description
Function detects the operating system and chooses the approximate kind of process for parallelizing the task: Windows: PSOCKCluster, Unix: Forking.
Usage
parpblapply(
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 list with the results.
Examples
square <- function(x) {
x * x
}
l <- parpblapply(X = 1:1000, FUN = square, export = c("square"), nNodes = 2)