parpbapply | R Documentation |
Function detects the operating system and chooses the approximate kind of process for parallelizing the task: Windows: PSOCKCluster, Unix: Forking.
parpbapply( X, FUN, MARGIN, packages = NULL, export = NULL, envir = environment(), nNodes = parallel::detectCores() - 1 )
X |
an array, including a matrix. |
FUN |
function, the function to be applied to each element of X |
MARGIN |
a vector giving the subscripts which the function will be applied over. E.g., for a matrix 1 indicates rows, 2 indicates columns, c(1, 2) indicates rows and columns. Where X has named dimnames, it can be a character vector selecting dimension names. |
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) |
Returns a vector or array or list of values obtained by applying a function to margins of an array or matrix.
n <- 1000 df <- data.frame( x = seq(1, n, 1), y = -seq(1, n, 1) ) a <- parpbapply(X = df, FUN = sum, MARGIN = 1, nNodes = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.