MENU

Fun & Interesting

Using dplyr & ggplot2 to make kindergarten vaccination rates a bit more interesting with R (CC337)

Riffomonas Project 714 3 months ago
Video Not Working? Fix It Now

Pat recreates a figure from the New York Times's UpShot showing the change US kindergarten vaccination rates because of the pandemic by state using tools from dplyr and ggplot2. The functions he uses from these packages include aes, annotate, arrange, as.numeric, coord_cartesian, drop_na, element_blank, element_line, element_rect, element_text, factor, filter, font_add_google, geom_segment, geom_text, ggplot, ggsave, if_else, labs, margin, mean, mutate, na_if, pivot_wider, pull, read_csv, scale_color_manual, scale_x_continuous, select, showtext_auto, showtext_opts, summarize, and theme. You can find the data and code he developed in this episode at https://riffomonas.org/code_club/2025-01-30-vaccination-arrows. The original NYT news article is available at: https://www.nytimes.com/interactive/2025/01/13/upshot/vaccination-rates.html. Pat's newsletter describing how he would go about generating the figure can be found at https://shop.riffomonas.org/posts/data-visualization-as-a-vaccination-against-ignorance. The csv file can be downloaded from https://data.cdc.gov/Vaccinations/Vaccination-Coverage-and-Exemptions-among-Kinderga/ijqb-a7ye/about_data. If you have a figure that you would like to see me discuss in a future newsletter and episode of Code Club, email me at [email protected]! Want more practice on the concepts covered in Code Club? You can sign up for my weekly newsletter at https://shop.riffomonas.org/youtube to get practice problems, tips, and insights. If you're interested in purchasing a video workshop be sure to check out https://riffomonas.org/workshops/ Support Riffomonas by becoming a Patreon member! https://www.patreon.com/riffomonas You can also find complete tutorials for learning R with the tidyverse using... Microbial ecology data: https://www.riffomonas.org/minimalR/ General data: https://www.riffomonas.org/generalR/ If you want to cite this video, please consider citing https://journals.asm.org/doi/10.1128/mra.01310-22 0:00 Introduction 3:55 Get data into R and in right format 14:39 Create segment plot with arrows 21:35 Put names by arrows and remove them from y-axis 29:25 Create colored background for US range 32:53 Add and stylize titles and x-axis 41:15 Add legend between title and plot

Comment