View source: R/averageGroupedStats.R
averageGroupedStats | R Documentation |
Average grouped statistics with consideration of weights and protection from missing values.
averageGroupedStats(values, grouping, weights = NULL)
values |
A numeric vector containing statistics for individual tests. |
grouping |
A vector or factor of length equal to Alternatively, an rle object where each run corresponds to a group and specifies the entries of |
weights |
A numeric vector of length equal to |
If weights
is supplied, a weighted average is computed for each group.
If values
contains missing values, they are ignored and will not contribute to the average.
A named numeric vector of (weighted) averages, of length equal to the number of unique levels in grouping
.
Aaron Lun
averageParallelStats
, for the parallel counterpart.
grouping <- sample(LETTERS, 20, replace=TRUE)
averageGroupedStats(1:20, grouping)
averageGroupedStats(1:20, grouping, weights=runif(20))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.