Assuming I have a data table (not data frame) that has columns of Year, Month, Day, Sales, and a new column Sales Last Year (Similar to the picture below), how do I create that Sales Last Year column to grab the Sales from the same day and month but one year ago?
Data
dt <- data.table(Month = rep("January", times = 3),
Year = 2016:2018,
Day = rep(1, times = 3),
Sales = c(5000, 1000, 2000))