applyByCategory {Category}R Documentation

Apply a function to a vector of statistics, by category

Description

The rows of the input matrix, Amat, define categories. For each row we split the values of stats into sets according to the categories and the apply FUN to each of the sets.

Usage

applyByCategory(stats, Amat, FUN = mean, ...)

Arguments

stats Test statistics of interest.
Amat A matrix with columns corresponding to values in stats and rows defining categorizations.
FUN A function to apply to the splits of stats by categories.
... Extra parameters passed to lapply and used by FUN.

Details

Pretty much all in the description field.

Value

The return value is a list of length equal to nrow(Amat). Each element of which corresponds to the values obtained by spliting the vector stats according to the categories defined for that row and then applying FUN to each resultant set.

Author(s)

R. Gentleman

See Also

split, apply

Examples

 st1 = rnorm(20)
 catM = matrix(sample(c(0,1), 60, replace=TRUE), nr=3)
 applyByCategory(st1, catM, median)


[Package Category version 1.0.1 Index]