parpbapply {eRTG3D}R Documentation

Parallel apply with progressbar

Description

Function detects the operating system and chooses the approximate kind of process for parallelizing the task: Windows: PSOCKCluster, Unix: Forking.

Usage

parpbapply(
  X,
  FUN,
  MARGIN,
  packages = NULL,
  export = NULL,
  envir = environment(),
  nNodes = parallel::detectCores() - 1
)

Arguments

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)

Value

Returns a vector or array or list of values obtained by applying a function to margins of an array or matrix.

Examples

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)

[Package eRTG3D version 0.7.0 Index]