EdwinTh / padr

Padding of missing records in time series
https://edwinth.github.io/padr/
Other
132 stars 12 forks source link

First day of start_val filtered out #73

Closed EdwinTh closed 3 years ago

EdwinTh commented 4 years ago

Carefully look if this is expected behaviour or a bug

https://stackoverflow.com/questions/61256217/thicken-date-range-using-padr-where-starting-value-is-the-same-as-one-of-the-dat

df_calls = data.frame(Call_date= c("2019-02-18",
                                   "2019-02-19",                                               
                                   "2019-02-20",                                               
                                   "2019-02-22",                                              
                                   "2019-02-25",                                              
                                   "2019-02-26",                                              
                                   "2019-03-01",                                              
                                   "2019-03-04"),
                      Calls = c(12,4,2,8,1,3,1,8))

starting_day= as.Date("2019-02-18")

df_calls_weekly = df_calls %>%
  mutate(Call_date = as.Date(Call_date)) %>% 
  thicken("week",colname = "Date_Week",start_val = starting_day) %>%
  group_by(Date_Week) %>%  
  summarise(Num_calls = sum(Calls)) %>%
  ungroup()
EdwinTh commented 3 years ago

It was indeed implemented this way, but I cannot think of a good reason to exclude the start day. It is also not documented as working as such, thus, changed it.