Generates choropleth maps and corresponding bar plots to visualize OCV vaccination data from WHO, GTFCC, or combined sources across African countries.
Arguments
- PATHS
A named list containing file paths required for input and output operations. It should include:
MODEL_INPUTDirectory path where the processed vaccination data files are located.
DOCS_FIGURESDirectory path where the generated plots will be saved.
- data_source
The source of the vaccination data. Must be one of
"WHO","GTFCC", or"BOTH". Default is"WHO".
Value
The function does not return any value. It generates and saves a PNG file containing the vaccination maps and barplots with annotations.
Details
The function performs the following steps:
Data Loading and Processing: Reads the vaccination data from a CSV file, converts the
datecolumn toDateobjects, and extracts the latest cumulative doses distributed and corresponding vaccination proportions for each country.Map Data Retrieval: Obtains map data for African countries using the
rnaturalearthpackage.Data Merging: Merges the vaccination data with the map data, identifying Sub-Saharan African countries based on ISO codes provided by the
MOSAIC::iso_codes_ssadataset.Color Scale Definition: Defines distinct color scales for cumulative doses distributed (green gradient) and proportion vaccinated (purple gradient), including appropriate breaks and labels.
Choropleth Map Creation: Creates two choropleth maps—one for cumulative doses distributed and another for the proportion vaccinated—using
ggplot2and layering map data accordingly.Barplot Generation: Constructs barplots for each metric, ordering countries by descending values and applying the corresponding color scales.
Plot Arrangement: Utilizes the
patchworkandcowplotpackages to arrange the maps and barplots into a structured grid with panel labels "A" and "B" and adds a footnote.Saving the Plot: Saves the final combined plot as a PNG file in the specified
DOCS_FIGURESdirectory.
Examples
if (FALSE) { # \dontrun{
# Define the PATHS list with appropriate directories
PATHS <- list(
MODEL_INPUT = "path/to/model/input",
DOCS_FIGURES = "path/to/docs/figures"
)
# Call the function to generate and save the vaccination maps
plot_vaccination_maps(PATHS)
plot_vaccination_maps(PATHS, data_source = "GTFCC")
plot_vaccination_maps(PATHS, data_source = "BOTH")
} # }
