@@ -567,16 +567,32 @@ epi_slide_mean = function(x, col_name, ..., before, after, ref_time_values,
567
567
# after <- time_step(after)
568
568
# }
569
569
570
- # time_step can be any of `c("days", "weeks", "months", "quarters", "years")`
571
- all_dates <- seq(min(x $ time_value ), max(x $ time_value ), by = time_step )
570
+ all_dates <- as.Date(c())
571
+ pad_early_dates <- as.Date(c())
572
+ pad_late_dates <- as.Date(c())
572
573
573
- pad_early_dates <- c()
574
- pad_late_dates <- c()
575
- if (before != 0 ) {
576
- pad_early_dates <- all_dates [1L ] - before : 1
577
- }
578
- if (after != 0 ) {
579
- pad_late_dates <- all_dates [length(all_dates )] + 1 : after
574
+ # Find `by` corresponding to epi_df `time_type` or `time_step`.
575
+ by <- ...
576
+
577
+ if (! is.null(by )) {
578
+ # time_step can be any of `c("days", "weeks", "months", "quarters", "years")`
579
+ # tidyr::full_seq(c(min(x$time_value), max(x$time_value)), period = 1) ?
580
+ all_dates <- seq(min(x $ time_value ), max(x $ time_value ), by = by )
581
+
582
+ if (before != 0 ) {
583
+ pad_early_dates <- Start(all_dates ) - before : 1
584
+ }
585
+ if (after != 0 ) {
586
+ pad_late_dates <- End(all_dates ) + 1 : after
587
+ }
588
+ } else {
589
+ Warn(
590
+ c(
591
+ " `frollmean` requires a full window to compute a result. Add NA values
592
+ to beginning and end of the group so that we get results for the
593
+ first `before` and last `after` elements."
594
+ )
595
+ )
580
596
}
581
597
582
598
# `frollmean` is 1-indexed, so create a new window width based on our
0 commit comments