Aggregate Values for Observations Aggregates values for observations. Accepts a list of formulas with result name on left and aggregating expression on the right. Behavior is undefined if any expression does not aggregate! (I.e., length != 1). Expressions are evaluated in an environment where values are available as 'x', grouped count is available as 'n' and ungouped count is available as 'N'.
# S3 method for observations
devalued(
x,
...,
fun = list(sum ~ sum(x, na.rm = TRUE), pct ~ signif(digits = 3, sum/n * 100), ave ~
signif(digits = 3, mean(x, na.rm = TRUE)), std ~ signif(digits = 3, sd(x, na.rm =
TRUE)), med ~ signif(digits = 3, median(x, na.rm = TRUE)), min ~ signif(digits = 3,
min(x, na.rm = TRUE)), max ~ signif(digits = 3, max(x, na.rm = TRUE))),
silent = TRUE
)
class 'devalued', presumably one record per group:
number of records
number of records in group
observation identifier
factor level (or special value 'numeric' for numerics)
additional column for each statistic in 'fun'
observations
passed formulas with matching LHS will replace corresponding element of fun.
default aggregate functions expressed as formulas
whether to suppress warnings from evaluations of 'fun'