Skip to content

Bug in time_delta_to_n_steps() #664

Open
@dajmcdon

Description

@dajmcdon

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions