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 17, 2024
1 parent 94a4d27 commit 7ac9c6e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 2 additions & 1 deletion R/slide.R
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,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
2 changes: 0 additions & 2 deletions tests/testthat/test-epi_slide.R
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,4 @@ test_that("epi_slide gets correct ref_time_value when groups have non-overlappin
slide_value = .ref_time_value)

expect_identical(result1, expected_output)


})

0 comments on commit 7ac9c6e

Please sign in to comment.