
Append trailing-average rows in long form to econanalyzr data frame
Source:R/econ_calc_trail_avg.R
econ_calc_trail_avg.RdComputes a trailing (right-aligned) moving average of value and appends
those rows to the original data (long form).
Details
Input must pass
check_econanalyzr_df().trail_amountmust be a positive, integer-ish scalar (e.g., 3L, 6).If
dfis a grouped tibble (viadplyr::group_by()), the trailing average is computed within each group. If ungrouped, it is computed over the entire table.Derived rows have
data_transform_textappended with"; Trail {n}".Windows are right-aligned with
.complete = TRUE: the firsttrail_amount - 1rows per group areNA.