Attaching package: 'rnaturalearthdata'
The following object is masked from 'package:rnaturalearth':
countries110
Code
library(dplyr)Malaria <-read.csv("National_Unit_data.csv")Incidence<- Malaria%>%filter(Metric =="Infection Prevalence"& Year =="2019")%>%mutate(Prevalence = Value)%>%select(c(ISO3, Prevalence))
Code
world_map <-ne_countries(scale ='medium', returnclass ="sf")map_data <- world_map %>%left_join(Incidence, by =c("iso_a3"="ISO3"))
Code
ggplot() +geom_sf(data = map_data, aes(fill = Prevalence)) +scale_fill_gradient(low ="white", high ="red", na.value ="gray", name ="Malaria Prevalence") +theme_minimal() +theme(axis.text =element_blank(), axis.ticks =element_blank(), axis.title =element_blank()) +labs(title ="Malaria Prevalence by Country")
Code
ggplot() +geom_sf(data = map_data, aes(fill = Prevalence)) +scale_fill_gradient(low ="white", high ="red", na.value ="gray", name ="Malaria Prevalence") +theme_minimal() +theme(axis.text =element_blank(), axis.ticks =element_blank(), axis.title =element_blank()) +labs(title ="Malaria Prevalence by Country") +facet_wrap(~ region_un)
Code
# # Filter to only include infection prevalence data for a specific year# Year <- 2019# Incidence <- Malaria %>%# filter(Metric == "Incidence Rate" & Units == "Cases per Thousand" & Year == Year) %>%# mutate(Incidence_Rate = Value) %>%# select(c(ISO3, Incidence_Rate))# # # Get world map data with medium scale# world_map <- ne_countries(scale = "medium", returnclass = "sf")# # # Join incidence data with world map data# map_data <- world_map %>%# left_join(Incidence, by = c("iso_a3" = "ISO3"))# # # Create the choropleth map using ggplot2# ggplot() +# geom_sf(data = map_data, aes(fill = Incidence_Rate)) +# scale_fill_gradient(low = "white", high = "red", na.value = "gray", name = "Malaria Incidence Rate") +# theme_minimal() +# theme(axis.text = element_blank(), axis.ticks = element_blank(), axis.title = element_blank()) +# labs(title = paste0("Malaria Incidence Rate by Country in ", Year))