mtapply: Multivariate tapply()

Description Usage Arguments Details Value See Also Examples

View source: R/mtapply.R

Description

Apply a function over an array by a list of indices. Multivariate version of tapply.

Usage

1
mtapply(X, INDEX, FUN = NULL, ...)

Arguments

X

Object where split is applicable. See tapply.

INDEX

List of indices. See tapply for univariate case.

FUN

Function to apply. See tapply.

...

Parameters passed to mapply.

Details

Unlike tapply, one can pass a list of datasets and indices to mtapply.

Value

List.

See Also

https://github.com/robertschnitman/afp, tapply, mapply, dot,

Examples

1
2
3
4
# For each variable in a dataset, obtain means by a different index.
A <- mtcars[, c('mpg', 'wt', 'disp')]  # Targets.
B <- mtcars[, c('gear', 'am', 'carb')] # Indices.
mtapply(A, B, mean)

robertschnitman/afp documentation built on Aug. 9, 2020, 9:46 a.m.