Skip to contents

add_scenario() wraps around add_scenario_indicator() to add the scenario specified in scenario_function to all the valid billionaiRe indicators present in df.

Usage

add_scenario(
  df,
  scenario_function = c("aroc", "halt_rise", "percent_baseline", "linear_change",
    "linear_change_col", "quantile", "best_in_region", "fixed_target",
    "fixed_target_col", "bau", "accelerate", "accelerate_target", "sdg", "benchmarking",
    "covid_rapid_return", "covid_delayed_return", "covid_sustained_disruption",
    "return_previous_trajectory", "top_n_iso3"),
  ind_ids = billion_ind_codes("all"),
  scenario_col = "scenario",
  start_year = 2018,
  end_year = 2025,
  default_scenario = "default",
  make_default = FALSE,
  start_scenario_last_default = TRUE,
  ...
)

add_scenario_indicator(
  df,
  scenario_function = c("aroc", "halt_rise", "percent_baseline", "linear_change",
    "linear_change_col", "quantile", "best_in_region", "fixed_target",
    "fixed_target_col", "bau", "accelerate", "accelerate_target", "sdg", "benchmarking",
    "covid_rapid_return", "covid_sustained_disruption", "covid_delayed_return",
    "covid_never_return", "return_previous_trajectory", "top_n_iso3"),
  indicator,
  start_year = 2018,
  ind_ids = billion_ind_codes("all"),
  scenario_col = "scenario",
  default_scenario = "default",
  bau_scenario = "historical",
  make_default = FALSE,
  expend_bau = FALSE,
  start_scenario_last_default = TRUE,
  ...
)

Arguments

df

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

scenario_function

character identifier of scenario to use. Can be any of the following:

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().

scenario_col

Column name of column with scenario identifiers. Useful for calculating contributions on data in long format rather than wide format.

start_year

Base year for contribution calculation, defaults to 2018.

end_year

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

default_scenario

name of the default scenario.

make_default

(Boolean) if TRUE, then make_default_scenario is used to generate the default_scenario

start_scenario_last_default

(Boolean) if TRUE, then the last year with values in the default_scenario is the starting point of the scenario, and not start_year.

...

additional parameters to be passed to the add_scenario_indicator function (e.g. add_scenario_adult_obese).

indicator

name of indicator to be passed to scenario_function

bau_scenario

name of scenario to be used for business as usual. Default is historical.

expend_bau

(Boolean)if TRUE, then make_default_scenario is used to expend bau_scenario to the start of the default_scenario.

Value

data frame with additional rows with scenario values.

Details

add_scenario_indicator() gets the right add_scenario_ function for the indicator specified and adds the scenario.