Let's say I have the following data.table.
library(data.table)
DT <- data.table(x=1:6, y=c(0,0,1,0,0,0))
Could I write some command DT[...] that selects all the rows within 2 rows of the one in which y=1? That is, using proximity to row three, I want to select rows 1-5.