parpbsapply | R Documentation |
Function detects the operating system and chooses the approximate kind of process for parallelizing the task: Windows: PSOCKCluster, Unix: Forking.
parpbsapply( X, FUN, packages = NULL, export = NULL, envir = environment(), nNodes = parallel::detectCores() - 1 )
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) |
A vector with the results.
square <- function(x) { x * x } s <- parpbsapply(X = 1:1000, FUN = square, export = c("square"), nNodes = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.