|
40 | 40 | #' the typical time during which most significant revisions occur. The default |
41 | 41 | #' of 60 days corresponds to a typical near-final value for case counts as |
42 | 42 | #' reported in the context of insurance. To avoid this filtering, either set |
43 | | -#' to `NULL` or 0. This will be rounded up to the appropriate `time_type` if |
| 43 | +#' to `NULL` or 0. A `difftime` will be rounded up to the appropriate `time_type` if |
44 | 44 | #' necessary (that is 5 days will be rounded to 1 week if the data is weekly). |
45 | 45 | #' @param within_latest double between 0 and 1. Determines the threshold |
46 | 46 | #' used for the `lag_to` |
@@ -88,8 +88,10 @@ revision_analysis <- function(epi_arch, |
88 | 88 | compactify_abs_tol = 0, |
89 | 89 | return_only_tibble = FALSE) { |
90 | 90 | assert_class(epi_arch, "epi_archive") |
91 | | - min_waiting_period <- min_waiting_period %>% |
92 | | - difftime_approx_ceiling_time_delta(epi_arch$time_type) |
| 91 | + if (methods::is(min_waiting_period, "difftime")) { |
| 92 | + min_waiting_period <- min_waiting_period %>% |
| 93 | + difftime_approx_ceiling_time_delta(epi_arch$time_type) |
| 94 | + } |
93 | 95 | # if the column to summarize isn't specified, use the only one if there is only one |
94 | 96 | if (dots_n(...) == 0) { |
95 | 97 | # Choose the first column that's not a key: |
@@ -225,8 +227,10 @@ print.revision_analysis <- function(x, |
225 | 227 | abs_spread_threshold = NULL, |
226 | 228 | rel_spread_threshold = 0.1, |
227 | 229 | ...) { |
228 | | - quick_revision <- quick_revision %>% |
229 | | - difftime_approx_ceiling_time_delta(x$time_type) |
| 230 | + if (methods::is(quick_revision, "difftime")) { |
| 231 | + quick_revision <- quick_revision %>% |
| 232 | + difftime_approx_ceiling_time_delta(x$time_type) |
| 233 | + } |
230 | 234 | if (is.null(abs_spread_threshold)) abs_spread_threshold <- .05 * x$max_val |
231 | 235 | rev_beh <- x$revision_behavior |
232 | 236 | cli::cli_h2("An epi_archive spanning {.val {x$range_time_values[1]}} to {.val {x$range_time_values[1]}}.") |
|
0 commit comments