Skip to content

Commit

Permalink
calculate all starts + before at once
Browse files Browse the repository at this point in the history
  • Loading branch information
nmdefries committed Jan 18, 2024
1 parent 96c83d6 commit 9e0d9ed
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/slide.R
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,9 @@ epi_slide <- function(x, f, ..., before, after, ref_time_values,
f_wrapper_factory <- function(starts) {
# Use `i` to advance through list of start dates.
i <- 1L
starts <- starts + before
f_wrapper <- function(.x, .group_key, ...) {
.ref_time_value <- starts[[i]] + before
.ref_time_value <- starts[[i]]
i <<- i + 1L
f(.x, .group_key, .ref_time_value, ...)
}
Expand Down

0 comments on commit 9e0d9ed

Please sign in to comment.