Apply.function | R Documentation |
Emulate parallel apply on a function, from mclapply. Returns a vector or array or list of values obtained by applying a function to margins of an array or matrix.
Apply.function( FUN, X, MARGIN = 1, .combine = c, .lapply = parallel::mclapply, ... )
FUN |
function to apply on X |
X |
array of input values for FUN |
MARGIN |
1 indicates to apply on rows (default), 2 on columns |
.combine |
how to combine results (default using c(.)) |
.lapply |
how to vectorize FUN call (default is parallel::mclapply) |
... |
optional arguments to FUN. |
array of values taken by FUN on each row/column of X
X = matrix(runif(10),ncol=2); rowSums(X) == apply(X,1,sum) apply(X,1,sum) == Apply.function(sum,X) X = matrix(runif(10),ncol=1) rowSums(X) == apply(X,1,sum) apply(X,1,sum) == Apply.function(sum,X) X = matrix(runif(10),ncol=2) f = function(X) X[1]/X[2] apply(X,1,f) == Apply.function(f,X)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.