summarize_over_time: Summarize Data over Time and Groups

summarize_over_timeR Documentation

Summarize Data over Time and Groups

Description

All apps should use this functions to do aggregations!

Usage

summarize_over_time(data_filtered)

Details

Aggregation over period: If data is missing during more than 25% of the most recent observations, the period is considered incomplete, no aggregated value is computed.

Aggregation over group: Groups aggregations use all the countries for which data is available. If a ratio is computed (e.g., per-captia measures, positivity rate), we only consider observations that have values both for the nominator and the denominator. E.g., in order to calculate tests per-capita for a continent, a country is only used if reports both test and population data.

This is a deviation from an older discussion in: https://github.com/dsbbfinddx/shinyfindapps/issues/142#issuecomment-1023435405

See discussiofn in: https://github.com/finddx/shinyfindapps/issues/142#issuecomment-1023435405

Examples


library(shinyfind)
library(dplyr)
. <- get_data_all()
data_all <- .$data_all
country_last_update_info <- .$country_last_update_info

time_start <- as.Date(max(data_all$time) - 367)
time_end <- as.Date(max(data_all$time) - 2)
data_filtered <-
  data_all |>
  filter(set == "country") |>
  select(-name, -set) |>
  left_join(country_last_update_info, by = "unit") |>
  filter(!is.na(last_update))|>
  filter(dplyr::between(
    time,
    as.Date(time_start),
    as.Date(time_end)
  ))
data_summarized_over_time <- shinyfind::summarize_over_time(data_filtered)
shinyfind::summarize_over_group(data_summarized_over_time, "income")
shinyfind::summarize_over_group(data_summarized_over_time, "who_region")

finddx/shinyfind documentation built on May 28, 2024, 8:37 p.m.