recycle_data: Recycle data between scenarios

View source: R/recycle_data.R

recycle_dataR Documentation

Recycle data between scenarios

Description

recycle_data() recycles data between the scenarios present in df to reduce size of tables stored. The function wraps around recycle_data_scenario_single() for all the scenarios present in the scenario_col column.

Usage

recycle_data(
  df,
  billion = c("hep", "hpop", "uhc"),
  value_col = "value",
  start_year = 2018,
  end_year = 2025,
  scenario_col = "scenario",
  default_scenario = "default",
  scenario_reported_estimated = "routine",
  scenario_covid_shock = "covid_shock",
  scenario_reference_infilling = "reference_infilling",
  include_projection = TRUE,
  recycle_campaigns = TRUE,
  ind_ids = NULL,
  trim_years = TRUE,
  start_year_trim = start_year,
  end_year_trim = end_year
)

recycle_data_scenario_single(
  df,
  scenario,
  billion = c("hep", "hpop", "uhc"),
  value_col = "value",
  start_year = 2018,
  end_year = 2025,
  scenario_col = "scenario",
  default_scenario = "default",
  scenario_reported_estimated = "routine",
  scenario_covid_shock = "covid_shock",
  scenario_reference_infilling = "reference_infilling",
  include_projection = TRUE,
  recycle_campaigns = TRUE,
  ind_ids = NULL,
  trim_years = FALSE,
  start_year_trim = start_year,
  end_year_trim = end_year,
  assert_data_calculations = TRUE
)

make_default_scenario(
  df,
  scenario = "default",
  billion = c("all", "hep", "hpop", "uhc"),
  value_col = "value",
  start_year = 2018,
  end_year = 2025,
  scenario_col = "scenario",
  default_scenario = "default",
  scenario_reported_estimated = "routine",
  scenario_covid_shock = "covid_shock",
  scenario_reference_infilling = "reference_infilling",
  include_projection = TRUE,
  recycle_campaigns = TRUE,
  ind_ids = NULL,
  trim_years = FALSE,
  start_year_trim = start_year,
  end_year_trim = end_year,
  assert_data_calculations = TRUE
)

Arguments

df

Data frame in long format, where 1 row corresponds to a specific country, year, and indicator.

billion

name of billion to recycle data for.

value_col

Column name of column with indicator values.

start_year

Base year for contribution calculation, defaults to 2018.

end_year

End year(s) for contribution calculation, defaults to 2019 to 2025.

scenario_col

Column name of column with scenario identifiers.

default_scenario

name of the default scenario.

scenario_reported_estimated

name of the reported/estimated scenario.

scenario_covid_shock

name of the scenario with the COVID-19 shock years.

scenario_reference_infilling

name of the WHO technical programs projections/imputations scenario.

include_projection

Boolean to include or not projections in recycling

recycle_campaigns

Boolean to include or not campaigns in recycling

ind_ids

Named vector of indicator codes for input indicators to the Billion. Although separate indicator codes can be used than the standard, they must be supplied as a named vector where the names correspond to the output of billion_ind_codes().

trim_years

logical to indicate if years before start_year and after end_year should be removed

start_year_trim

(integer) year to start trimming from.

end_year_trim

(integer) year to end trimming.

scenario

name of scenario to recycle for.

assert_data_calculations

Boolean if true then output data frame will be tested to see if it contains the minimal required data to run the calculations.

Details

make_default_scenario() wraps around recycle_data_scenario_single() to create a default scenario based on the parameters passed to the function.

recycle_data_scenario_single() reuses values present in the specified scenarios in default_scenario, scenario_reported_estimated, scenario_covid_shock and scenario_reference_infilling for the specified scenarios.

To do so, it looks at:

  1. values in default_scenario but not in the scenario specified

  2. values in scenario_reported_estimated or scenario_covid_shock but not in the scenario specified or default_scenario.

  3. values in scenario_reference_infilling but not in the scenario specified, scenario_reported_estimated, scenario_covid_shock, or scenario_reference_infilling

For more information see:

vignette("scenarios", package = "billionaiRe")

See Also

Functions to recycle the data remove_recycled_data()


gpw13/billionaiRe documentation built on Sept. 27, 2024, 10:05 p.m.