View source: R/connected_scatterplot.R
prep_epi_data | R Documentation |
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.
prep_epi_data(df, sel_cntry, year_range)
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. |
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.
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
.
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.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.