Aggregates trial-level values within bins and optional grouping variables, producing a tidy table suitable for grouped time-series analysis.
Usage
aggregate_by_bin(
data,
value,
bin,
by = NULL,
bins = NULL,
fun = mean,
na_rm = TRUE,
complete = TRUE,
out = NULL
)Arguments
- data
data.frame containing the value and bin columns.
- value
character scalar naming the value column to aggregate.
- bin
character scalar naming the bin column.
- by
optional character vector of grouping columns.
- bins
optional vector of target bins. If
NULL, uses the sorted unique non-missing values observed indata[[bin]].- fun
summary function applied within each bin.
- na_rm
logical; if
TRUE, remove missing values before applyingfun.- complete
logical; if
TRUE, return explicit rows for missing group/bin combinations withNAsummaries.- out
optional output column name. Defaults to
value.