Skip to content

date windows behaving unexpectedly #100

Description

@danwwilson

Firstly, let me express my sincere appreciation for this package. It's been super helpful when dealing with rolling measure on date data with gaps.

I came across a behaviour that seemed strange to me and I wanted to check my understanding (and maybe report a bug).

The following reprex shows the issue I've encounted.

  library(data.table)
  dt  <- data.table(
    date = as.Date(c("2025-07-01", "2025-08-01", "2025-09-01")),
    b = c(10, 20, 30)
  )
  
  dt[,
    let(
      rolling_2m= runner(x=b, k = "2 months", idx = date, f = sum, na_pad = TRUE))]
  dt
#          date     b rolling_2m
#        <Date> <num>      <num>
# 1: 2025-07-01    10         NA
# 2: 2025-08-01    20         NA
# 3: 2025-09-01    30         50

I'm curious to understand why the second record doesn't end up with a value in rolling_2m when it's the second month. Any guidance here would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions