data.table is awesome, because I can do rolling joins, and even do rolling joins within groups!
data.table
library(data.table) set.seed(42) metrics &l
metrics[calendar, roll = TRUE, rollends = c(TRUE, TRUE)]