Skip to contents

Choose a single best `time_scale` for each year in a dataset, grouped by nesting disease. This best `time_scale` is defined as the longest of the shortest time scales in each location and sub-disease.

Usage

normalize_time_scales(
  data,
  initial_group = c("year", "iso_3166", "iso_3166_2", "disease", "nesting_disease",
    "basal_disease"),
  final_group = c("basal_disease"),
  get_implied_zeros = TRUE,
  aggregate_if_unavailable = TRUE
)

Arguments

data

A tidy data set with columns `time_scale`, `period_start_date` and `period_end_date`.

initial_group

Character vector naming columns for defining the initial grouping used to compute the shortest time scales.

final_group

Character vector naming columns for defining the final grouping used to compute the longest of the shortest time scales.

get_implied_zeros

Add zeros that are implied by a '0' reported at a coarser timescale.

aggregate_if_unavailable

If a location is not reporting for the determined 'best timescale', but is reporting at a finer timescale, aggregate this finer timescale to the 'best timescale'.

Value

A data set only containing records with the optimal time scale.