ia_election_2020 | R Documentation |
Precinct level results from the 2020 general election for all Iowa precincts (except for Scott county). Precinct level election results for the US was provided under an MIT license by the NYTimes UpShot team at from https://github.com/TheUpshot/presidential-precinct-map-2020 The data provided here only covers Iowa precincts.
ia_election_2020
A tibble with 1597 rows and 7 columns
unique identifier for the precinct: 5-digit zipcode followed by the precinct name or ID
numeric, number of total votes
numeric value, number of votes for Joseph Biden
numeric value, number of votes for Donald Trump
numeric value, indicating the percent of the democratic lead over the republican
numeric value, number of votes per square kilometer
sf object of precinct level maps
NY Times Upshot
https://github.com/TheUpshot/presidential-precinct-map-2020
library(sf)
library(leaflet)
pal <- colorNumeric(palette=c("Darkred", "White", "Darkblue"),
reverse = FALSE,
domain = range(ia_election_2020$pct_dem_lead, na.rm=TRUE))
# Percent of Democratic lead over the Republican
ia_election_2020 %>%
leaflet() %>%
addTiles() %>%
addPolygons(fillColor = ~pal(pct_dem_lead), fillOpacity = .75,
stroke=0, opacity = .7, label=~GEOID) %>%
addLegend(pal=pal, values = range(ia_election_2020$pct_dem_lead, na.rm=TRUE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.