Voter Registrations Are Way, Way Down During the Pandemic

FiveThirtyEight article (Jun 26, 2020) by Kaleigh Rogers and Nathaniel Rakich

The original article can be found at:

https://fivethirtyeight.com/features/voter-registrations-are-way-way-down-during-the-pandemic/

Tasks

Accessing the Data

# Load the tidyverse 
library(tidyverse)

# Import data 
vreg<-read.csv("https://raw.githubusercontent.com/fivethirtyeight/data/master/voter-registration/new-voter-registrations.csv",
header=TRUE)

Hints/Tips

1. Relevel the data

# Level the Month variable so that its in the right order (ie not alphabetical)
vreg$Month<-factor(vreg$Month,
                   levels=c("Jan", "Feb", "Mar", "Apr", "May"))

2. Tidy the data

### USE spread() FROM tidyr 

vregYear<-vreg%>%
spread(Year, New.registered.voters)

### RENAME THE COLUMNS
colnames(vregYear)<-c("Jurisdiction", "Month", "Y2016", "Y2020")

3. Mutate to add the change

### mutate() FROM dplyr() 
vregChange<-vregYear%>%
mutate(change=Y2020-Y2016)

4. Other hints

  • You can add another column to define color
vregChange<-vregYear%>%
  mutate(change=Y2020-Y2016)%>%
  mutate(direction=change>=0)
  • Pay careful attention to the axes, you might want to read the help file for facet_wrap

Final Product

The code has been hidden, however, your final graphic should look like this: