add_scenario: Add scenario to data frame

View source: R/add_scenarios.R

add_scenarioR Documentation

Add scenario to data frame

Description

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", include_calculated = TRUE),
  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", include_calculated = TRUE),
  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:

  • aroc: calls scenario_aroc

  • halt_rise: calls scenario_halt_rise

  • percent_baseline: calls scenario_percent_baseline

  • linear_change: calls scenario_linear_change

  • linear_change_col: calls scenario_linear_change_col

  • quantile: calls scenario_quantile

  • best_in_region: calls scenario_best_in_region

  • fixed_target: calls scenario_fixed_target

  • fixed_target_col: calls scenario_fixed_target_col

  • bau: calls scenario_bau

  • accelerate: calls indicator accelerate function.

  • accelerate_target: calls indicator accelerate function to specified targets.

  • sdg: calls Sustainable Development Goals (SDG) acceleration function.

  • benchmarking: calls benchmarking scenarios.

  • covid_rapid_return calls scenario_covid_rapid_return

  • covid_delayed_return calls scenario_covid_delayed_return

  • covid_sustained_disruption calls scenario_covid_sustained_disruption

  • return_previous_trajectory calls scenario_return_previous_trajectory

  • top_n_iso3 calls scenario_top_n_iso3

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.

Details

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

Value

data frame with additional rows with scenario values.

See Also

General scenario functions calculate_aarc(), calculate_aroc(), exec_scenario(), fill_cols_scenario(), flat_extrapolation(), get_aarr(), get_baseline_value(), get_baseline_year(), get_last_value(), get_last_year_scenario(), get_latest_aarc(), get_percent_change_aarc(), get_target_aarc(), remove_unwanted_scenarios(), trim_values(), trim_years()


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