This document gives solutions to the questions posed in Project 3. I had a bit of fun with some of these, and included additional tweaks that make the output look a bit nicer. These were not expected in my grading of the projects.
Question Show a spatial visualization (i.e., a map) of the infection rate (cases per population) in the U.S. on 1 May 2020, 15 June 2020, and 1 October for the “lower 48” states (no Hawaii, Alaska, or Puerto Rico). Also, separately show the infection rate for Hawaii on 15 June 2020. Try to describe the patterns in a few short sentences. Make sure to use appropriate projections and color scales.
Solution Notes I included explicit limits in the color scale in order to make the maps comparable to one another. For Hawaii, I manually set the limits of the x and y axes to zoom in on the actual data (there must be a better way to do this automatically, but I could not figure out how). I also included thick outlines for Hawaii; these are often too busy for counties but look nice when looking at island chains.
%>% county inner_join(filter(covid, date == "2020-05-01"), by = c("fips", "state")) %>% inner_join(demog, by = c("fips", "state")) %>% mutate(infect_rate = cases / population * 100000) %>% filter(!(state %in% c("HI", "AK", "PR"))) %>% st_transform(3083) %>% ggplot() + geom_sf(aes(fill = infect_rate), size = 0) + scale_fill_distiller( trans = "log2", palette = "Spectral", guide = "legend", n.breaks = 10, limits = c(2, 8192) + ) labs(fill = "Infection Rate\n (per 100k)") + theme_void()