Skip to content

Bug in time_delta_to_n_steps() #664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dajmcdon opened this issue Apr 22, 2025 · 1 comment
Open

Bug in time_delta_to_n_steps() #664

dajmcdon opened this issue Apr 22, 2025 · 1 comment

Comments

@dajmcdon
Copy link
Contributor

dajmcdon commented Apr 22, 2025

Discovered while trying to use revision_summary() on weekly data.

When the data have weekly time_value but the version is not on the same day of the week, everything chokes.

suppressMessages(library(epiprocess))
suppressMessages(library(tidyverse))

set.seed(0)
dat <- tibble(
  time_value = seq(ymd("2020-01-01"), by = "1 week", length.out = 10),
  version = time_value + days(round(runif(10, 2, 6))),
  geo_value = rep("ca", 10),
  value = rnorm(10)
) |>
  as_epi_archive()

revision_summary(dat, value)
#> Error in `mutate()`:
#> ℹ In argument: `lag = time_minus_time_in_n_steps(version, time_value,
#>   time_type)`.
#> Caused by error in `time_delta_to_n_steps()`:
#> ! `time_delta` did not appear to contain only integerish numbers of
#>   steps between time values of time type "week"


epiprocess:::time_delta_to_n_steps(as.difftime(3, units = "days"), "week")
#> Error in `epiprocess:::time_delta_to_n_steps()`:
#> ! `time_delta` did not appear to contain only integerish numbers of
#>   steps between time values of time type "week"

Created on 2025-04-22 with reprex v2.1.1

@brookslogan
Copy link
Contributor

I coded this mistakenly thinking that time_value and version would be of the same "time type". Treating this as a sub-issue of #653.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants