Calculate HPOP Indicator Contributions
Source:R/calculate_hpop_contributions.R
calculate_hpop_contributions.Rd
calculate_hpop_contributions()
calculates indicator-level contributions and
changes for the HPOP Billion.
Usage
calculate_hpop_contributions(
df,
start_year = 2018,
end_year = 2019:2025,
transform_value_col = "transform_value",
contribution_col = stringr::str_replace(transform_value_col, "transform_value",
"contribution"),
contribution_pct_col = paste0(contribution_col, "_percent"),
contribution_pct_total_pop_col = paste0(contribution_col, "_percent_total_pop"),
scenario_col = NULL,
ind_ids = billion_ind_codes("hpop")
)
Arguments
- df
Data frame in long format, where 1 row corresponds to a specific country, year, and indicator.
- start_year
Base year for contribution calculation, defaults to 2018.
- end_year
End year(s) for contribution calculation, defaults to 2019 to 2025.
- transform_value_col
Column name of column(s) with transformed indicator values, used to calculate contributions.
- contribution_col
Column name of column(s) to store contribution (population) values. Must be the same length as
transform_value_col
.- contribution_pct_col
Column name of column(s) to store contribution (percent) values. Must be the same length as
transform_value_col
.- contribution_pct_total_pop_col
Column name of column(s) to store contribution (percent of total population of the country) values. Must be the same length as
transform_value_col
.- scenario_col
Column name of column with scenario identifiers. Useful for calculating contributions on data in long format rather than wide format.
- 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()
.
Details
For more details on the HPOP Billion calculation process and how this function ties in with the rest, see the vignette: