In this assignment, I visualize the percentage of Trump voters in 2016 within Palm Beach County.
library(tidyverse)
library(sf)
fl_2016 <- st_read("/Users/dalia/Downloads/fl_2016/fl_2016.shp")
## Reading layer `fl_2016' from data source
## `/Users/dalia/Downloads/fl_2016/fl_2016.shp' using driver `ESRI Shapefile'
## Simple feature collection with 6116 features and 18 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY, XYZ
## Bounding box: xmin: -87.6349 ymin: 24.39631 xmax: -79.97431 ymax: 31.00097
## z_range: zmin: 0 zmax: 0
## Geodetic CRS: NAD83
fl_2016 <- st_make_valid(fl_2016)
fl_2016_PalmBeach <- fl_2016 |>
filter(COUNTY == "PAL")
ggplot(data = fl_2016_PalmBeach) +
geom_sf(data = fl_2016_PalmBeach, aes(fill = trump_pct), color = "black", alpha = 0.7) +
theme_minimal() +
scale_fill_gradient2(low = "blue", mid = "white", high = "red",
midpoint = 0.5,
limits = c(0, 1),
na.value = "grey50",
name = "2016 Trump %") +
labs(title = "Palm Beach County")