Introduction

In this document, we visualize the precinct-level results of the 2020 Presidential election in Miami-Dade County, Florida. Our goal is to display Trump and Biden support using a gradient map, where red indicates precincts with higher Trump support, and blue indicates precincts with higher Biden support.

Data Filtering

First, we filter the election data to include only Miami-Dade County (DAD).

fl_2020 <- st_read("C:/Users/alesa/OneDrive/Desktop/grad school/POS 6933/fl_2020/fl_2020.shp")

fl_2020 <- st_make_valid(fl_2020)

fl_2020_mia <- fl_2020 %>%
  filter(COUNTY == "DAD")

Calculating Trump Support

Next, we calculate the total votes in each precinct and compute the percentage of Trump support. The mutate function helps create new columns for total_votes and trump_support.

fl_2020_DAD <- fl_2020_mia %>%
  mutate(
  total_votes = (G20PRERTRU + G20PREDBID),
  trump_support = (G20PRERTRU / total_votes) * 100)

Creating the Map

We now visualize the data on a map using ggplot2 and geom_sf to handle spatial data.

ggplot() +
  geom_sf(data = fl_2020_DAD, aes(fill = trump_support), color = "black", alpha = 0.7) +
  theme_minimal() +
  scale_fill_gradient2(low = "blue", mid = "white", high = "red",
                      midpoint = 50,
                      limits = c(0, 100), 
                      na.value = "grey50",  
                      name = "2020 Trump %") +  
  labs(title = "Miami Dade County")