Skip to contents

Introduction

This vignette covers how to access the clean and tidy annual UNAIDS Estimates from GitHub Releases. The MindTheGap package uses a cleaning function (munge_unaids) to process, munge, and tidy the UNAIDS HIV Estimates from AIDSInfo and pull_unaids to pull the cleaned data from Google Drive.

Let’s start by loading the MindTheGap package.

library(mindthegap)
library(glamr) #install.packages('glamr', repos = c('https://usaid-oha-si.r-universe.dev', getOption("repos")))
library(knitr)

Pull clean data from GitHub Releases

With munge_unaids, the developer is left with a clean and tidy dataset that includes a pepfar flag to denote whether a country is a PEPFAR country or not and an estimate_flag to indicate estimates that are an approximation (previously contained a “<”). In order to make this data accessible outside of R and cut down on the processing time, we uploaded the clean UNAIDS data to the package releases and wrote the function pull_unaids for users to easily access this data.

To use pull_unaids, there are 2 parameters:

  1. data_type: This parameter returns one of the 2 datasets: “HIV Estimates” or “HIV Test & Treat”. Please note that if you want to filter to a specific indicator type (i.e. Percent or Integer), you will have to add that filter to your code filter(indic_type == "Integer").

  2. pepfar_only: if TRUE, this parameter will return a dataset of only PEPFAR countries. If you do not specify this parameter, it will default to TRUE.

In order to access the data from GitHub releases, be sure to load the glamr package to run the pull_unaids function.

df_est <- pull_unaids(data_type = "HIV Estimates", pepfar_only = TRUE)

kable(head(df_est), format = "html")
year iso country region indicator age sex estimate lower_bound upper_bound estimate_flag sheet indic_type pepfar achv_95_plhiv achv_95_relative epi_ratio_2023 epi_control
1990 KHM Cambodia Asia and the Pacific Number AIDS Related Deaths All All 100 100 100 TRUE HIV Estimates Integer TRUE FALSE FALSE 0.7608939 TRUE
1990 KHM Cambodia Asia and the Pacific Number AIDS Related Deaths 0-14 All 100 100 100 TRUE HIV Estimates Integer TRUE FALSE FALSE 0.7608939 TRUE
1990 KHM Cambodia Asia and the Pacific Number AIDS Related Deaths 15+ All 100 100 100 TRUE HIV Estimates Integer TRUE FALSE FALSE 0.7608939 TRUE
1990 KHM Cambodia Asia and the Pacific Number PLHIV 0-14 All 100 100 100 TRUE HIV Estimates Integer TRUE FALSE FALSE 0.7608939 TRUE
1990 KHM Cambodia Asia and the Pacific Number PLHIV 15+ Female 200 200 200 TRUE HIV Estimates Integer TRUE FALSE FALSE 0.7608939 TRUE
1990 KHM Cambodia Asia and the Pacific Number PLHIV 15+ All 500 500 500 TRUE HIV Estimates Integer TRUE FALSE FALSE 0.7608939 TRUE