Preface
This code is a portion of a larger research project that includes a difference-in-difference analysis of voter turnout across two election years. This project was presented at the 2023 Southern Political Science Association Annual Conference.
Introduction
In the spring of 2020, I was a freshman Political Science student in Florida. On Wednesday, March 11th I received an email from my university telling me that, due to the Covid-19 pandemic, students were to be sent home for 2-3 weeks. On March 13th I packed up most of my dorm and drove 7 hours back to South Florida. Thousands of students across the state and country had identical experiences that week.
In the midst of this chaos, the Presidential Preference Primary (PPP) was set to be held in the state on March 17th, just days following the mass migration of students. I was interested in how the pandemic impacted voter youth voter turnout in this election. In my case, I remained registered in my home county and was able to vote on election day at my usual precinct. But thousands of other students had re-registered to their college towns and no longer had time to request a mail-in ballot.
To analyze this question, I use the state Voter File and Vote History file to compare the turnout of on-campus students to that of youth voters of similar ages who did not live on campus, but instead in surrounding areas.
The assumption that while students who lived on campus were specifically asked to leave their dorms, students who lived off-campus or youth voters who were unaffiliated with the university would not see the same disruption in their living situation and could have remained where they were registered.
Research Design and Data
For the purposes of eliminating any potential confounding variables, we chose to only examine the four Florida public university that had on-campus precincts. These schools were: The University of Florida, Florida State University, University of South Florida, and University of Central Florida. We combined the Voter File data from their four respective counties and combined it with the Vote History file using a left_join function for Voter ID numbers.
To do so we first read in the March 2020 Florida Voter File and conduct necessary data cleaning. We unify the capitalization for party affiliation and recode race form their codes to written word. Using an age function, we add an additional column to indicate the age of the voter on the exact day of the election, March 17th 2020.
# create new variables
FLRecap <- FLRecap %>% mutate(VoterID = as.numeric(VoterID))
FLRecap <- FLRecap %>%
mutate(
# Limit parties to dem, rep, npa, other
PartyAffiliation = case_when(
tolower(PartyAffiliation) == "dem" ~ "DEM",
tolower(PartyAffiliation) == "rep" ~ "REP",
tolower(PartyAffiliation) == "npa" ~ "NPA",
TRUE ~ "Other"),
# Edit race column
Race = case_when(
Race == 3 ~ 'Black',
Race == 4 ~ 'Hispanic',
Race == 5 ~ 'White',
TRUE ~ 'Other'),
# Adjust date fields
BirthDate = as.Date(BirthDate, "%m/%d/%Y"),
RegistrationDate = as.Date(RegistrationDate, "%m/%d/%Y"),
# Reformat registration date, separated by "-"
reg.date = ymd(RegistrationDate),
# Make voter ID a numeric column
VoterID = as.numeric(VoterID)) %>%
separate(reg.date, sep="-", into = c("reg.year", "reg.month", "reg.day"),
)
FLRecap$Age <- age(FLRecap$BirthDate,"2020-03-17")
#Creating Age Categories
FLRecap <- FLRecap %>%
mutate(
Agecat = case_when(
Age >= 18 & Age < 24 ~ "18-23",
Age >= 24 & Age < 30 ~ "24-29",
Age >= 30 & Age < 45 ~ "30-44",
Age >= 45 & Age < 65 ~ "45-64",
Age >= 65 & Age < 106 ~ "65-105",
TRUE ~ "Other"
),
Agecat2 = case_when(
Age >= 18 & Age < 21 ~ "18-20",
Age >= 21 & Age < 30 ~ "21-29",
Age >= 30 & Age < 45 ~ "30-44",
Age >= 45 & Age < 65 ~ "45-64",
Age >= 65 & Age < 106 ~ "65-105",
TRUE ~ "Other"
)
)Here we filter out the voter file to only include the age group of interest. While this is not the proper filter to determine on-campus students, it does allow R to work faster with a smaller file. Next we combine our Voter File data with the matching Vote History File. I removed all columns except for vote method and voter ID number, which will join the files. Next, I cleaned the mailing address information and added a binary variable to indicates if the individual had voted at all, regardless of method.
######################################
# Filtering out Data for Age Cat #
######################################
# Filtering just 18 up to 24 year olds
FL2020PPP <- FLRecap %>%
filter(Agecat == "18-23")
remove(FLRecap)
#####################################
# Merging in Vote History #
#####################################
#naming vote history columns
colname_VoteHist <-c("CountyCode", "VoterID", "X1", "VoteDate", "VoteHistoryCode", "Precinct",
"District", "District", "District")
VoteHistory <- Sys.glob(paths = "~/Dropbox/FL_Rutgers/data/olddata/RecapHistory_Payton/*")
#loading vote history file
VoteHistoryFile <- load_voter_file(VoteHistory, colname_VoteHist)## New names:
## New names:
## New names:
## New names:
## • `District` -> `District...7`
## • `District` -> `District...8`
## • `District` -> `District...9`
# Dropping column I don't need
VoteHistoryFile$District...6 <- NULL
VoteHistoryFile$District...7 <- NULL
VoteHistoryFile$District...8 <- NULL
VoteHistoryFile$District...9 <- NULL
VoteHistoryFile$X10 <- NULL
VoteHistoryFile$X11 <- NULL
VoteHistoryFile$X1 <- NULL
VoteHistoryFile$CountyCode <- NULL
VoteHistoryFile$VoteHistoryCode <- NULL
VoteHistoryFile$Precinct <- NULL
VoteHistoryFile$VoterID <- as.numeric(VoteHistoryFile$VoterID)
#combining the files
FL2020PPP <- left_join(x = FL2020PPP, y = VoteHistoryFile, by = "VoterID",
copy = T)
#Get rid of other file
remove(VoteHistoryFile)
# Filtering out on-campus students
FL2020PPP$ResidenceAddressLine1 <- toupper(FL2020PPP$ResidenceAddressLine1)
#Fixing zip code problem
FL2020PPP$ResidenceZipcode <- substr(FL2020PPP$ResidenceZipcode, 0, 5)
FL2020PPP$MailingZipcode <- substr(FL2020PPP$MailingZipcode, 0, 5)
# make a dichotomous variable of whether or not they voted regardless of method
FL2020PPP$Vote_Binary <- with(FL2020PPP,
ifelse(VoteHistoryCode == "N", 0,1)) On-Campus Students
In order to determine our on-campus students, the file was first divided out by county. Independently, I determined that for 3 out of 4 of the schools, only on-campus students would be registered to the on-campus precinct. Therefore, for those schools I was able to further filter the file by precinct. For the last school, Florida State University, I examined the voter file to determine how on-campus students had listed their address. After confirming this pattern, I individually filtered the file to include all dorm addressesm on the university campus. The four files were then rejoined to create one on-campus file.
#############################
# uf #
#############################
#filter out by county and then by precinct
on_campus_uf <- FL2020PPP %>%
filter(CountyCode == "ALA")
on_campus_uf <- on_campus_uf %>%
filter(Precinct == "31")
#############################
# ucf #
#############################
on_campus_ucf <- FL2020PPP %>%
filter(CountyCode == "ORA")
on_campus_ucf <- on_campus_ucf %>%
filter(Precinct == "538")
#############################
# usf #
#############################
on_campus_usf <- FL2020PPP %>%
filter(CountyCode == "HIL")
on_campus_usf <- on_campus_usf %>%
filter(Precinct == "353")
#############################
# fsu and famu #
#############################
on_campus_fsu <- FL2020PPP %>%
filter(CountyCode == "LEO")
on_campus_fsu <- on_campus_fsu %>%
filter(ResidenceAddressLine1 == "0 AZALEA HALL " | ResidenceAddressLine1 == "0 BROWARD HALL "
| ResidenceAddressLine1 == "0 BRYAN HALL " | ResidenceAddressLine1 == "0 CAWTHON HALL "
| ResidenceAddressLine1 == "0 DEGRAFF HALL " | ResidenceAddressLine1 == "0 DORMAN HALL "
| ResidenceAddressLine1 == "0 DEVINEY HALL " | ResidenceAddressLine1 == "0 GILCHRIST HALL "
| ResidenceAddressLine1 == "0 JENNIE MURPHREE HALL " | ResidenceAddressLine1 == "0 LANDIS HALL "
| ResidenceAddressLine1 == "0 MAGNOLIA HALL " | ResidenceAddressLine1 == "0 REYNOLDS HALL "
| ResidenceAddressLine1 == "0 SALLEY HALL " | ResidenceAddressLine1 == "0 WILDWOOD HALL")
############################
# Data Visualization #
############################
#making a bar graph
all_on_campus <- on_campus_fsu
all_on_campus <- rbind(all_on_campus, on_campus_ucf)
all_on_campus <- rbind(all_on_campus, on_campus_uf)
all_on_campus <- rbind(all_on_campus, on_campus_usf)Before data visualization, I completed some last minute data cleaning on the Vote History file to get rid of date errors and deleted a date that one county did not have early voting on.
# just for early vote
vote_date <- all_on_campus %>%
filter(VoteHistoryCode =="E")
vote_date_2 <- data.frame(table(vote_date$VoteDate, vote_date$CountyCode))
#### remove days that shouldn't be there
vote_date_2 <- vote_date_2 %>%
filter(Var1 != "01/01/1880")
vote_date_2 <- vote_date_2 %>%
filter(Var1 != "03/17/2020")
#deleting that one day of early vote that alachua doesnt have by deleting the row
vote_date_2 <- vote_date_2[-14,]
#making the dates easier to read
vote_date_2$Var1 <- substr(vote_date_2$Var1, 0, 5)Data Visualization
Below we can see an interesting representation of early voting in the PPP in 2020. Most notably with the University of Florida, we see a sharp decrease in early votes around the time of the campus evacuation order.
Conclusions
Obviously, from this very brief snippet of code, no conclusions may be drawn. I later went on to replicate the code for three additional group: Off-campus voters in the PPP, On-campus voters in the 2020 General Election, and Off-campus voters in the 2020 General Election. Then, I conducted a difference-in-difference analysis comparing the turnout of the two groups from the primary to the general.
##### Making a line plot of all on campus voters who voted early
ggplot(data = vote_date_2, aes(x=Var1, y=Freq, group=Var2, color=Var2))+
geom_line()+
geom_point(size = 1)+
labs(title = "Early Vote in the 2020 PPP",
subtitle = "FL Universities with on-campus precincts")+
xlab("Date")+
ylab("Vote Count")+
theme_classic()+
theme(axis.text.x = element_text(size = 6,
angle = 0))+
guides(color = guide_legend(title = "University"))+
scale_color_manual(labels = c("UF", "USF", "FSU", "UCF"),
values = c("dodgerblue3", "green4", "red3", "goldenrod1") )