ElectProject / Early-Vote-2020G

Tracker for 2020 general election early vote (mail and in-person) activity
110 stars 20 forks source link

[FEATURE REQUEST] Turnout as a percentage 2016 turnout by this date. #490

Closed FredeJ closed 4 years ago

FredeJ commented 4 years ago

It would be nice to see how much turnout is up compared to 2016 at this time. Though I'm not sure if that data is available 🤷‍♀️

1beb commented 4 years ago

Here's 2016 Turnout from David Leip's Election Atlas

# David Leip Data
library(xml2)
library(rvest)
url <- "https://uselectionatlas.org/RESULTS/data.php?year=2016&datatype=national&def=1&f=0&off=0&elect=0"
r <- read_html(url)
tabs <- r %>% html_table(fill = TRUE) 
tab <- tabs[[4]]

df <- data.frame(
  state = tab$X3, 
  votes = as.integer(gsub(",", "", tab$X7)), 
  stringsAsFactors = F
)

df <- df[3:(nrow(df)-2),]
dput(df)
structure(list(state = c("Alabama", "Alaska", "Arizona", "Arkansas", 
"California", "Colorado", "Connecticut", "Delaware", "D. C.", 
"Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", 
"Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", 
"Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", 
"Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", 
"New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", 
"Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", 
"South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", 
"Washington", "West Virginia", "Wisconsin", "Wyoming"), votes = c(2123372L, 
318608L, 2604657L, 1130635L, 14237893L, 2780247L, 1644920L, 443814L, 
311268L, 9502747L, 4141447L, 428937L, 690433L, 5594825L, 2757965L, 
1566031L, 1194755L, 1924150L, 2029032L, 747927L, 2781446L, 3325046L, 
4824542L, 2945233L, 1211088L, 2828266L, 501822L, 844227L, 1125385L, 
744296L, 3906723L, 798319L, 7721795L, 4741564L, 344360L, 5536547L, 
1452992L, 2001336L, 6166729L, 464144L, 2103027L, 370093L, 2508027L, 
8993166L, 1143601L, 315067L, 3982752L, 3316996L, 721233L, 2976150L, 
255849L)), row.names = 3:53, class = "data.frame")
ElectProject commented 4 years ago

Thanks much. I have my own source for turnout, if you check electproject.org :) and that is populated on the % 2016 turnout tab.