4040# ' the typical time during which most significant revisions occur. The default
4141# ' of 60 days corresponds to a typical near-final value for case counts as
4242# ' reported in the context of insurance. To avoid this filtering, either set
43- # ' to `NULL` or 0.
43+ # ' to `NULL` or 0. This will be rounded up to the appropriate `time_type` if
44+ # ' necessary (that is 5 days will be rounded to 1 week if the data is weekly).
4445# ' @param within_latest double between 0 and 1. Determines the threshold
4546# ' used for the `lag_to`
4647# ' @param compactify bool. If `TRUE`, we will compactify after the signal
8182revision_analysis <- function (epi_arch ,
8283 ... ,
8384 drop_nas = TRUE ,
84- min_waiting_period = as.difftime(60 , units = " days" ) %> %
85- difftime_approx_ceiling_time_delta(epi_arch $ time_type ),
85+ min_waiting_period = as.difftime(60 , units = " days" ),
8686 within_latest = 0.2 ,
8787 compactify = TRUE ,
8888 compactify_abs_tol = 0 ,
8989 return_only_tibble = FALSE ) {
9090 assert_class(epi_arch , " epi_archive" )
91+ min_waiting_period <- min_waiting_period %> %
92+ difftime_approx_ceiling_time_delta(epi_arch $ time_type )
9193 # if the column to summarize isn't specified, use the only one if there is only one
9294 if (dots_n(... ) == 0 ) {
9395 # Choose the first column that's not a key:
@@ -203,7 +205,8 @@ revision_analysis <- function(epi_arch,
203205# ' @param quick_revision Difftime or integer (integer is treated as days).
204206# ' The amount of time between the final revision and the
205207# ' actual time_value to consider the revision quickly resolved. Default of 3
206- # ' days
208+ # ' days. This will be rounded up to the appropriate `time_type` if
209+ # ' necessary (that is 5 days will be rounded to 1 week if the data is weekly).
207210# ' @param few_revisions Integer. The upper bound on the
208211# ' number of revisions to consider "few". Default is 3.
209212# ' @param abs_spread_threshold Scalar numeric. The
@@ -217,12 +220,13 @@ revision_analysis <- function(epi_arch,
217220# ' @rdname revision_analysis
218221# ' @export
219222print.revision_analysis <- function (x ,
220- quick_revision = as.difftime(3 , units = " days" ) %> %
221- difftime_approx_ceiling_time_delta(x $ time_type ),
223+ quick_revision = as.difftime(3 , units = " days" ),
222224 few_revisions = 3 ,
223225 abs_spread_threshold = NULL ,
224226 rel_spread_threshold = 0.1 ,
225227 ... ) {
228+ quick_revision <- quick_revision %> %
229+ difftime_approx_ceiling_time_delta(x $ time_type )
226230 if (is.null(abs_spread_threshold )) abs_spread_threshold <- .05 * x $ max_val
227231 rev_beh <- x $ revision_behavior
228232 cli :: cli_h2(" An epi_archive spanning {.val {x$range_time_values[1]}} to {.val {x$range_time_values[1]}}." )
0 commit comments