This is totally related to #3223 and the new shift behavior from #1708. I just want to point out that the new behavior caused some old code to break due to naming inconsistencies. I think the best option here is to adapt to using type = "shift" with negative values, but it definitely threw me for a loop.
# Minimal reproducible example
dat <- data.table(a = 1:3, b = 2:4)
## Using data.table 1.12.2
dat[ , data.table::shift(.SD, 0:1, give.names = TRUE, type = "lead")]
# a_lag_0 a_lead_1 b_lag_0 b_lead_1
# 1: 1 2 2 3
# 2: 2 3 3 4
# 3: 3 NA 4 NA
## Using data.table 1.11.8
dat[ , data.table::shift(.SD, 0:1, give.names = TRUE, type = "lead")]
# a_lead_0 a_lead_1 b_lead_0 b_lead_1
# 1: 1 2 2 3
# 2: 2 3 3 4
# 3: 3 NA 4 NA
# Output of sessionInfo()
R-3.5.1; data.table 1.12.2 & 1.11.8
This is totally related to #3223 and the new
shiftbehavior from #1708. I just want to point out that the new behavior caused some old code to break due to naming inconsistencies. I think the best option here is to adapt to usingtype = "shift"with negative values, but it definitely threw me for a loop.#Minimal reproducible example#Output of sessionInfo()R-3.5.1; data.table 1.12.2 & 1.11.8