View source: R/implicitExpansion.R
| mmapply | R Documentation |
Similar function to mapply with support for implicit expansion.
mmapply( FUN, ..., MoreArgs = list(), SIMPLIFY = TRUE, USE.NAMES = TRUE, ALLOW.RECYCLING = FALSE )
FUN |
Function to apply to each combination of arguments. Found via |
... |
Objects that are coerced to arrays, expanded using implicit expansion, and then vectorized over. |
MoreArgs |
Pass arguments in a list instead of |
SIMPLIFY |
If |
USE.NAMES |
If |
ALLOW.RECYCLING |
Whether to allow recycling of elements in each dimension. |
Most arguments are handled in a similar fashion to mapply with some key differences:
Entries of MoreArgs are treated the same as the ones in ..., i.e.
mmapply(...) is the same as mmapply(MoreArgs = list(...)).
Additional arguments to FUN can be passed here or in ..., either as they are
(if they are atomic), or as a list() of length one.
SIMPLIFY only simplifies a list array to an atomic array, nothing else.
USE.NAMES uses names from all arguments, but never uses an argument itself as names.
If ALLOW.RECYCLING is set to TRUE, all arrays of any size are compatible.
An array containing the result of FUN for each combination of entries from ... after implicit expansion.
expandArray, expandedDim
summaries <- list(Max = max, Min = min, avg = mean)
data <- list(a = 1:5, b = 2:3, c = 20:12)
formatStrings <- array(c('%.1f', '%.3f'), c(1,1,2))
mmapply(function(f, d, s) sprintf(s, f(d)), summaries, t(data), formatStrings)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.