R for public health: a short course on wrangling and visualizing data in R, including spatial data
Course materials: https://michaeldgarber.github.io/teach-r/
This short course introduced participants to popular tools in R for manipulating (“wrangling”) and visualizing data through public-health-focused examples. The course focused on tools that are a part of and that work well with the tidyverse. Specifically, packages covered include dplyr and sf for manipulating data, and ggplot2, mapview, and tmap for visualizing data.
Many examples transition back and forth between data with and without a spatial component, showing that working with and visualizing spatial data need not require separate specialized geographic information systems (GIS) software.
For example:
#Load packages
library(mapview)
library(here)
library(sf)
library(tidyverse)
#Load data. Data were gathered separately via tidycensus
setwd(here("data-processed"))
load("county_ga_wrangle.RData")
county_ga_wrangle %>%
dplyr::select(pop, county_name,geometry) %>% #select a subset of variables
rename(Population=pop) %>% #rename the population variable
mapview(zcol="Population",layer.name="Population")#make an interactive map
Copyright © 2025 Michael D. Garber