To calculate the HPOP Billion, there are a series of functions made available through the billionaiRe package:
-
transform_hpop_data()
to transform raw values into normalized values used within the calculations. -
add_hpop_populations()
to get relevant population groups for each country and indicator. -
calculate_hpop_contributions()
to calculate indicator level changes and contributions to the Billion. -
calculate_hpop_billion()
to calculate indicator level changes, country-level Billion, adjusting for double counting, and all contributions.
Run in sequence, these can calculate the entire HPOP Billion, or they
can be run separately to produce different outputs as required. Details
on the inputs of each function are available in their individual
documentation, but below you can see the quick and easy Billions
calculation done using the sample fake HPOP data provided in the
package, hpop_df
.
library(billionaiRe)
hpop_df %>%
transform_hpop_data() %>%
add_hpop_populations() %>%
calculate_hpop_billion() %>%
dplyr::filter(stringr::str_detect(ind, "hpop_healthier"))
#> # A tibble: 6 × 10
#> iso3 year ind value type trans…¹ popul…² contr…³ contr…⁴ contr…⁵
#> <chr> <dbl> <chr> <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 AFG 2023 hpop_healthie… NA NA NA 4.45e7 2.72e7 61.2 NA
#> 2 AFG 2023 hpop_healthie… NA NA NA 4.45e7 -3.84e7 -86.3 NA
#> 3 AFG 2023 hpop_healthier NA NA NA 4.45e7 -1.12e7 -25.1 NA
#> 4 AFG 2023 hpop_healthie… NA NA NA 4.45e7 3.20e7 71.9 NA
#> 5 AFG 2023 hpop_healthie… NA NA NA 4.45e7 -7.46e7 -168. NA
#> 6 AFG 2023 hpop_healthie… NA NA NA 4.45e7 -4.26e7 -95.7 NA
#> # … with abbreviated variable names ¹transform_value, ²population,
#> # ³contribution, ⁴contribution_percent, ⁵contribution_percent_total_pop