applyByCategory {Category} | R Documentation |
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.
applyByCategory(stats, Amat, FUN = mean, ...)
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 . |
Pretty much all in the description field.
The return value is a list of length equal to nrow(Amat)
. Each
element of which corresponds to the values obtained by split
ing
the vector stats
according to the categories defined for that
row and then apply
ing FUN
to each resultant set.
R. Gentleman
st1 = rnorm(20) catM = matrix(sample(c(0,1), 60, replace=TRUE), nr=3) applyByCategory(st1, catM, median)