| shard_apply_matrix | R Documentation |
A convenience wrapper for the common "per-column apply" pattern. The matrix is shared once and each worker receives a zero-copy column view when possible.
shard_apply_matrix(
X,
MARGIN = 2,
FUN,
VARS = NULL,
workers = NULL,
...,
policy = shard_apply_policy()
)
X |
A numeric/integer/logical matrix (or a shared matrix created by |
MARGIN |
Must be 2 (columns). |
FUN |
Function of the form |
VARS |
Optional named list of extra variables. Large atomic VARS are
auto-shared based on |
workers |
Number of workers (passed to |
... |
Additional arguments forwarded to |
policy |
A |
Current limitation: MARGIN must be 2 (columns). Row-wise apply would require
strided/gather slicing and is intentionally explicit in shard via views/kernels.
An atomic vector of length ncol(X) with the results.
X <- matrix(rnorm(400), 20, 20)
shard_apply_matrix(X, MARGIN = 2, FUN = mean)
pool_stop()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.