Skip to content

Commit 7ac9c6e

Browse files
committed
calculate all starts + before at once
1 parent 94a4d27 commit 7ac9c6e

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

R/slide.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,9 @@ epi_slide = function(x, f, ..., before, after, ref_time_values,
351351
f_wrapper_factory = function(starts) {
352352
# Use `i` to advance through list of start dates.
353353
i <- 1L
354+
starts <- starts + before
354355
f_wrapper = function(.x, .group_key, ...) {
355-
.ref_time_value = starts[[i]] + before
356+
.ref_time_value = starts[[i]]
356357
i <<- i + 1L
357358
f(.x, .group_key, .ref_time_value, ...)
358359
}

tests/testthat/test-epi_slide.R

-2
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,4 @@ test_that("epi_slide gets correct ref_time_value when groups have non-overlappin
567567
slide_value = .ref_time_value)
568568

569569
expect_identical(result1, expected_output)
570-
571-
572570
})

0 commit comments

Comments
 (0)