mmapply {implicitExpansion}R Documentation

Apply a Function to Multiple Arrays with Implicit Expansion

Description

Similar function to mapply with support for implicit expansion.

Usage

mmapply(
  FUN,
  ...,
  MoreArgs = list(),
  SIMPLIFY = TRUE,
  USE.NAMES = TRUE,
  ALLOW.RECYCLING = FALSE
)

Arguments

FUN

Function to apply to each combination of arguments. Found via match.fun.

...

Objects that are coerced to arrays, expanded using implicit expansion, and then vectorized over.

MoreArgs

Pass arguments in a list instead of ...

SIMPLIFY

If TRUE, the resulting list array is simplified to an atomic array if possible.

USE.NAMES

If TRUE, the dimensions are named using the names of input arguments of matching size.

ALLOW.RECYCLING

Whether to allow recycling of elements in each dimension.

Details

Most arguments are handled in a similar fashion to mapply with some key differences:

If ALLOW.RECYCLING is set to TRUE, all arrays of any size are compatible.

Value

An array containing the result of FUN for each combination of entries from ... after implicit expansion.

See Also

expandArray, expandedDim

Examples

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)


[Package implicitExpansion version 0.1.0 Index]