Skip to contents

Those scenarios allow to reach a target value from a baseline year by target year.

scenario_fixed_target() provides values for scenarios stated as "Reach XX% in INDICATOR by YEAR" or "Eliminate XX by YEAR".

scenario_fixed_target_col() wraps around scenario_fixed_target to provide targets from a column specified in target_col rather than a single value.

scenario_halt_rise() is a special case of scenario_fixed_target_col() where each country aims at a value of a specific year.

The returned scenario is a portion of the straight line drawn from the baseline_year value to the target_year. Only values for years between start_year and end_year will be returned.

If value_col has values that are higher or lower than the scenario values, then only value_col will be kept, depending on small_is_best. For instance, if the scenario value is 80 and the value 75 and small_is_best is TRUE, then 75 will be kept.

Usage

scenario_fixed_target(
  df,
  target_value,
  value_col = "value",
  scenario_col = "scenario",
  start_year = 2018,
  end_year = 2025,
  baseline_year = start_year,
  target_year = end_year,
  scenario_name = glue::glue("{target_value}_{target_year}"),
  small_is_best = FALSE,
  trim = TRUE,
  keep_better_values = TRUE,
  upper_limit = 100,
  lower_limit = 0,
  trim_years = TRUE,
  start_year_trim = start_year,
  end_year_trim = end_year,
  ind_ids = billion_ind_codes("all"),
  default_scenario = "default"
)

scenario_fixed_target_col(
  df,
  value_col = "value",
  scenario_col = "scenario",
  start_year = 2018,
  end_year = 2025,
  baseline_year = start_year,
  target_col = "target",
  target_year = end_year,
  scenario_name = glue::glue("{target_col}_{target_year}"),
  small_is_best = FALSE,
  trim = TRUE,
  keep_better_values = TRUE,
  upper_limit = 100,
  lower_limit = 0,
  trim_years = TRUE,
  start_year_trim = start_year,
  end_year_trim = end_year,
  ind_ids = billion_ind_codes("all"),
  default_scenario = "default"
)

scenario_halt_rise(
  df,
  value_col = "value",
  start_year = 2018,
  end_year = 2025,
  baseline_year = start_year,
  target_year = end_year,
  scenario_col = "scenario",
  scenario_name = glue::glue("halt_rise"),
  upper_limit = 100,
  lower_limit = 0,
  trim = TRUE,
  keep_better_values = FALSE,
  small_is_best = FALSE,
  trim_years = TRUE,
  start_year_trim = start_year,
  end_year_trim = end_year,
  ind_ids = billion_ind_codes("all"),
  default_scenario = "default"
)

Arguments

df

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

target_value

value to be achieved by scenario by target_year

value_col

Column name of column with indicator values.

scenario_col

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

start_year

Start year for scenario, defaults to 2018.

end_year

End year for scenario, defaults to 2025

baseline_year

Year from which the scenario is measured. Defaults to start_year

target_year

Year by which the scenario should eventually be achieved. Defaults to end_year

scenario_name

Name of the scenario. Defaults to scenario_percent_change_baseline_year

small_is_best

Logical to identify if a lower value is better than a higher one (e.g. lower obesity in a positive public health outcome, so obesity rate should have small_is_best = TRUE).

trim

logical to indicate if the data should be trimmed between upper_limit and lower_limit.

keep_better_values

logical to indicate if "better" values should be kept from value_col if they are present. Follows the direction set in small_is_best. For instance, if small_is_best is TRUE, then value_col lower than col will be kept.

upper_limit

limit at which the indicator should be caped. Can take any of "guess", or any numeric. guess (default) will take 100 as the limit if percent_change is positive, and 0 if negative.

lower_limit

limit at which the indicator should be caped. Can take any of "guess", or 0 to 100. guess (default) will take 0 as the limit if percent_change is positive, and 100 if negative.

trim_years

logical to indicate if years before start_year_trim and after end_year_trim should be removed

start_year_trim

(integer) year to start trimming from.

end_year_trim

(integer) year to end trimming.

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

default_scenario

name of the default scenario to be used.

target_col

name of column with targets