Skip to content

Commit

Permalink
use case_when to avoid converting numeric -> Date
Browse files Browse the repository at this point in the history
  • Loading branch information
nmdefries committed Oct 15, 2024
1 parent be608ca commit 2768552
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/testthat/test-utils_latency.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ old_data <- tibble(
tmp_death_rate = atan(0.1 * 1:200) + cos(5 * 1:200) + 1
) %>%
# place2 is slightly more recent than place1
mutate(time_value = as.Date(ifelse(geo_value == "place2", time_value + 1, time_value))) %>%
mutate(time_value = case_when(
geo_value == "place2" ~ time_value + 1,
TRUE ~ time_value
)) %>%
as_epi_df(as_of = as_of)
old_data
keys <- c("time_value", "geo_value")
Expand Down

0 comments on commit 2768552

Please sign in to comment.