6161# ' Using a `time_type` of `"integer"` with week numbers like 202501 will
6262# ' produce incorrect results for some calculations, since week numbering
6363# ' contains jumps at year boundaries.
64- # '
64+ # '
6565# ' @return An S3 object with class `revision_behavior`. This function is typically
6666# ' called for the purposes of inspecting the printed output. The
67- # ' results of the computations are available in
67+ # ' results of the computations are available in
6868# ' `revision_analysis(...)$revision_behavior`. If you only want to access
6969# ' the internal computations, use `return_only_tibble = TRUE`.
7070# '
@@ -186,7 +186,7 @@ revision_analysis <- function(epi_arch,
186186 if (! return_only_tibble ) {
187187 revision_behavior <- structure(list (
188188 revision_behavior = revision_behavior ,
189- range_time_values = range(epi_arch $ DT $ time_value ),
189+ range_time_values = range(epi_arch $ DT $ time_value ),
190190 signal_variable = arg ,
191191 drop_nas = drop_nas ,
192192 time_type = time_type ,
@@ -227,35 +227,34 @@ print.revision_analysis <- function(x,
227227 abs_spread_threshold = NULL ,
228228 rel_spread_threshold = 0.1 ,
229229 ... ) {
230- cli :: cli_h2(" An epi_archive spanning {.val {x$range_time_values[1]}} to {.val {x$range_time_values[1]}}." )
230+ rev_beh <- x $ revision_behavior
231+ cli :: cli_h2(" An epi_archive spanning {.val {rev_beh$range_time_values[1]}} to {.val {rev_beh$range_time_values[1]}}." )
231232 cli :: cli_h3(" Min lag (time to first version):" )
232- time_delta_summary(x $ revision_behavior $ min_lag , x $ time_type ) %> % print()
233+ time_delta_summary(rev_beh $ min_lag , x $ time_type ) %> % print()
233234 if (! x $ drop_nas ) {
234235 cli_inform(" Fraction of all versions that are `NA`:" )
235236 cli_li(num_percent(x $ total_na , x $ n_obs , " " ))
236237 cli_inform(" " )
237238 }
238239 cli :: cli_h3(" Fraction of epi_key + time_values with" )
239- total_num <- nrow(x $ revision_behavior ) # nolint: object_usage_linter
240- total_num_unrevised <- sum(x $ n_revisions == 0 ) # nolint: object_usage_linter
240+ total_num <- nrow(rev_beh ) # nolint: object_usage_linter
241+ total_num_unrevised <- sum(rev_beh $ n_revisions == 0 ) # nolint: object_usage_linter
241242 cli_inform(" No revisions:" )
242243 cli_li(num_percent(total_num_unrevised , total_num , " " ))
243244 total_quickly_revised <- sum( # nolint: object_usage_linter
244- time_delta_to_n_steps(x $ revision_behavior $ max_lag , x $ time_type ) < =
245+ time_delta_to_n_steps(rev_beh $ max_lag , x $ time_type ) < =
245246 time_delta_to_n_steps(quick_revision , x $ time_type )
246247 )
247248 cli_inform(" Quick revisions (last revision within {format_time_delta(quick_revision, x$time_type)}
248249 of the `time_value`):" )
249250 cli_li(num_percent(total_quickly_revised , total_num , " " ))
250- total_barely_revised <- sum( # nolint: object_usage_linter
251- x $ n_revisions < = few_revisions
252- )
251+ total_barely_revised <- sum(x $ n_revisions < = few_revisions )
253252 cli_inform(" Few revisions (At most {few_revisions} revisions for that `time_value`):" )
254253 cli_li(num_percent(total_barely_revised , total_num , " " ))
255-
254+
256255 cli :: cli_h3(" Fraction of revised epi_key + time_values which have:" )
257-
258- real_revisions <- x $ revision_behavior %> % filter(n_revisions > 0 ) # nolint: object_usage_linter
256+
257+ real_revisions <- rev_beh %> % filter(n_revisions > 0 ) # nolint: object_usage_linter
259258 n_real_revised <- nrow(real_revisions ) # nolint: object_usage_linter
260259 rel_spread <- sum( # nolint: object_usage_linter
261260 real_revisions $ rel_spread < rel_spread_threshold ,
@@ -268,12 +267,12 @@ print.revision_analysis <- function(x,
268267 ) # nolint: object_usage_linter
269268 cli_inform(" Spread of more than {abs_spread_threshold} in actual value (when revised):" )
270269 cli_li(num_percent(abs_spread , n_real_revised , " " ))
271-
270+
272271 # time_type_unit_pluralizer[[time_type]] is a format string controlled by us
273272 # and/or downstream devs, so we can paste it onto our format string safely:
274273 units_plural <- pluralize(paste0(" {qty(2)}" , time_type_unit_pluralizer [[x $ time_type ]])) # nolint: object_usage_linter
275274 cli :: cli_h3(" {toTitleCase(units_plural)} until within {x$within_latest*100}% of the latest value:" )
276- time_delta_summary(x $ revision_behavior [[" lag_near_latest" ]], x $ time_type ) %> % print()
275+ time_delta_summary(rev_beh [[" lag_near_latest" ]], x $ time_type ) %> % print()
277276}
278277
279278# ' @export
0 commit comments