Skip to content

Commit 9e0d9ed

Browse files
committed
calculate all starts + before at once
1 parent 96c83d6 commit 9e0d9ed

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

R/slide.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,9 @@ epi_slide <- function(x, f, ..., before, after, ref_time_values,
356356
f_wrapper_factory <- function(starts) {
357357
# Use `i` to advance through list of start dates.
358358
i <- 1L
359+
starts <- starts + before
359360
f_wrapper <- function(.x, .group_key, ...) {
360-
.ref_time_value <- starts[[i]] + before
361+
.ref_time_value <- starts[[i]]
361362
i <<- i + 1L
362363
f(.x, .group_key, .ref_time_value, ...)
363364
}

0 commit comments

Comments
 (0)