10: Election Maps
Data Wrangling and Visualization
Introduction
For this assignment, you will draw a series of maps using R. Start by reading and following Healy, “Draw a Map”. Pay special attention to how Healy works with layout, projection, and the like.
Note that, to use Healy’s scripts, you need to install his libraries, which he identifies here:
https://socviz.co/index.html#install
The election data for his geography chapter is contained in those packages. You can just load them all. If you want to be judicious, you can just install packages needed for the chapter:
install.packages(c("socviz", "sf", "statebins", "ggrepel", "maps"))And then load just those packages for his maps chapter code to work (including election data):
library(tidyverse) # ggplot2, dplyr, etc.
library(socviz) # election24, states_sf, counties_sf, opiates, %nin%, theme_map()
library(sf) # needed for geom_sf() and the *_sf objects
library(statebins) # geom_statebins()
library(ggrepel) # geom_label_repel() in the opiates time-series plot
library(maps) # state outlinesAssignment
Create maps for the 2024 election following the Healy guidelines. In particular, make sure that your finalized maps include:
- 2024 Election Winner by State
- 2024 Election Winner by County
- Population Density by County
- % Black by County
Next, use 2026 election returns at the state level.1 Show:
- 2026 Senate Winner
- 2026 Governor Winner
Create maps that show swing (i.e., how much change there was) from the 2024 presidential election to 2026, by state, for:
- 2026 Senate
- 2026 Governor
Plot the (rough) location of Syracuse University on a national state map in a big blue or orange star.
Showcase!! Identify a spatial phenomenon of interest across the United States (it can be points, areas, or otherwise) and plot it. Guidelines:
- Use good cartography principles in the design of your maps.
- You should make at least two maps. They can show a related, or even the same, phenomenon, but the maps themselves should be different somehow: a different way of displaying the data, or a different variable being mapped, etc.
- You are also encouraged, although not required, to illustrate the phenomenon of interest using other graphs or visuals, as well.
- Use good cartography principles in the design of your maps.
- Some of the data you need is found in Healy’s package; some of the data is found in the course drive, and some you need to provide yourself.
- 2024 data is provided through Healy’s examples.
- Preliminary 2026 data you can use can be found in the course drive as
2026_midterms_prelim.csv. You can use this data for your assignment, but remember: it is preliminary. - You must also provide your own data for Syracuse University’s location, along with whatever data of your own interest you wish to map, for questions 4-5.
- You’re likely to be doing some merging in this assignment. For reference, we covered
joincommands back in our week on data manipulation. The key is to always make sure you know what your unique merge identifier is.
Submission
Make sure your GitHub repo contains at least 4 things:
- Your R script(s).
- A quarto file that addresses or answers the steps above and includes your graphics. Your quarto file can include your R code or your R code can remain separate in your R scripts, with the quarto file reading in figures from the project directory.
- A compiled quarto file, as a PDF, that includes your maps.
- Your original data, if necessary, in a format readable by R. (If you read data directly from a web source in your script, you can skip this step.)
Make sure that your quarto writeup includes a clear definition of your maps for question 5, as well as a summary description of what is particularly noteworthy about the features of your maps. It should also document the source of the data, and note steps done to manage the data (if any) before your R script(s) took over.
To submit your assignment to Blackboard, submit a clickable link to your GitHub repo as well as the original images from question 5 you want to display for the class showcase.
AI use is allowed on this and every problem set that is graded check/no check in this class. You should disclose any AI use as a matter of standard professional ethics, but you will not be evaluated on whether or not you used AI.
I encourage you, however, to use AI intelligently: use it like a teaching assistant to help you understand the material, not as a bot to automatically solve the problem set for you. Remember that you will not have access to a chatbot during in-class exams, so the problem sets are your chance to practice.
Footnotes
Midterm elections do not have races in every state. Make sure your data workflow deals with this properly!↩︎