prep_epi_data: Prepare UNAIDS Epidemiological Data for Analysis

View source: R/connected_scatterplot.R

prep_epi_dataR Documentation

Prepare UNAIDS Epidemiological Data for Analysis

Description

This function filters and processes UNAIDS epidemiological data by selecting relevant indicators ("Number Total Deaths to HIV Population" and "Number New HIV Infections"), reshaping the data into a wide format, and renaming the resulting columns for readability. It is intended to prepare the dataset for a race to the bottom visualization.

Usage

prep_epi_data(df, sel_cntry, year_range)

Arguments

df

A data frame containing the pre-processed UNAIDS EDMS data.

sel_cntry

A character vector of country names for which data should be filtered. The function will filter the dataset to include only these countries.

year_range

A numeric vector specifying the range of years to filter the dataset by. Only data within this range will be retained.

Details

The function first filters the data to include only the selected countries (sel_cntry), specified year range (year_range), and the indicators "Number Total Deaths to HIV Population" and "Number New HIV Infections". It selects columns relevant for further analysis, reshapes the data into a wide format, and renames the indicator columns to deaths and infections for better readability. If no data matches the provided filters, an error is thrown to inform the user.

Value

A filtered and reshaped data frame containing the selected countries, indicators, and years. The resulting data frame includes columns for region, country, year, iso, pepfar, and estimates of deaths and infections.

Note

This function assumes that the dataset includes all age and sex categories set to "All". Make sure to provide a correctly formatted dataset and verify country names to avoid errors.

Examples

## Not run: 
  # Load a sample UNAIDS dataset
  df_unaids <- load_unaids() # Assume this function loads your dataset

  # Prepare data for Lesotho for the years 2010-2023
  df_prepared <- prep_epi_data(df_unaids, sel_cntry = "Lesotho", year_range = 2010:2023)

## End(Not run)

USAID-OHA-SI/mindthegap documentation built on Jan. 19, 2025, 3:16 a.m.