Trailing rolling aggregates over a datetime window, usable inside mutate().
For each row, the aggregate covers the rows whose time falls in
(time - every, time] – the row itself and everything within one window
before it. With an upstream group_by(), windows are computed within each
group. NA values are skipped.
Usage
roll_sum(x, time, every)
roll_mean(x, time, every)
roll_min(x, time, every)
roll_max(x, time, every)
roll_n(time, every)Details
time must be a Date or POSIXct column; every is a fixed-width
duration string ("15 min", "1 hour", "7 days") – calendar units
(month, year) are not allowed because their length varies.