I am having trouble working roll=-Inf while defining rollends=FALSE . If rollends not installed or not set to TRUE , I see the expected result. I would be grateful for any suggestions.
library(data.table) dt1 = data.table(Date=seq(from=as.Date("2013-01-03"), to=as.Date("2013-06-27"), by="1 week"), key="Date")[, ind:=.I] dt2 = data.table(Date=seq(from=as.Date("2013-01-01"), to=as.Date("2013-06-30"), by="1 day"), key="Date")
I expect to see that 2013-01-05 and 2013-06-26 filled in the output below.
dt1[dt2, roll=-Inf, rollends=FALSE] Date ind 1: 2013-01-01 NA 2: 2013-01-02 NA 3: 2013-01-03 1 4: 2013-01-04 2 5: 2013-01-05 NA --- 177: 2013-06-26 NA 178: 2013-06-27 26 179: 2013-06-28 NA 180: 2013-06-29 NA 181: 2013-06-30 NA
This works as expected, the data ind rolls forward, but not beyond the endpoints defined in dt1 data.table .
dt1[dt2, roll=-Inf] Date ind 1: 2013-01-01 1 2: 2013-01-02 1 3: 2013-01-03 1 4: 2013-01-04 2 5: 2013-01-05 2 --- 177: 2013-06-26 26 178: 2013-06-27 26 179: 2013-06-28 NA 180: 2013-06-29 NA 181: 2013-06-30 NA
source share