library(tidyverse)
library(timetk)
# Lags
m4_monthly %>%
group_by(id) %>%
tk_augment_lags(contains("value"), .lags = 1:20)
# Leads
m4_monthly %>%
group_by(id) %>%
tk_augment_leads(value, .lags = 1:-20)
Run the code above in your browser using DataLab