chunk_apply {matter} | R Documentation |
Perform equivalents of lapply
and apply
, but over parallelized chunks of the data. This is most useful if accessing the data is potentially time-consuming, such as for file-based matter
objects. Operating on chunks reduces the number of IO operations.
chunk_apply(X, FUN, MARGIN, ..., simplify = FALSE, chunks = NA, view = c("element", "chunk"), attr = list(), alist = list(), outfile = NULL, verbose = FALSE, BPREDO = list(), BPPARAM = bpparam())
X |
A list, vector, or matrix. These may be any class that implements suitable methods for |
FUN |
The function to be applied. |
MARGIN |
If the object is matrix-like, which dimension to iterate over. Must be 1 or 2, where 1 indicates rows and 2 indicates columns. The dimension names can also be used if |
... |
Additional arguments to be passed to |
simplify |
Should the result be simplified into a vector, matrix, or higher dimensional array? |
chunks |
The number of chunks to use. If |
view |
What should be passed as the argment to |
attr |
A list of attributes that will be attached to the argument passed to |
alist |
A list of vector-like attributes that will be attached to the argument passed to |
outfile |
If non-NULL, a file path where the results should be written as they are processed. Not implemented yet. |
verbose |
Should user messages be printed with the current chunk being processed? |
BPREDO |
See documentation for |
BPPARAM |
An optional instance of |
Typically, a list if simplify=FALSE
. Otherwise, the results may be coerced to a vector or array.
Kylie A. Bemis
register(SerialParam()) set.seed(1) x <- matrix(rnorm(1000^2), nrow=1000, ncol=1000) out <- chunk_apply(x, mean, 1, chunks=20, verbose=TRUE)