The provided dashboard showcases an interactive map visualizing U.S. county voting patterns from 1916 to 2020. Users can explore vote shares by party, examine trends over time, and dive into county-level data. On the second page of the dashboard, each county is categorized by voting trends, with visualizations showing aggregated (by sum) vote percentages by category, the location of counties in each category, and individual county’s vote share across the years.
Each county was categorized into 1/4 broad voting trends: 1) Trending Moderately to Very Republican 2) Trending Slightly to Moderately Republican 3) Trending Slightly Democratic/Republican (i.e. relatively unchanged over time) and 4) Trending Slightly to Very Democratic. The way these categories were determined were by running a linear regression on every county predicting the vote share of the Republican Party from the election year, which were standardized (1,2,3…) to include counties that didn’t exist until later years. Negative regression coefficients indicated a trends towards the Democrats while positive coefficients indicated trends towards Republicans. The regression coefficients were then split into quartiles (0-25%, 25-50%, 50-75%, 75-100%) to determine the categories. Read more about linear regression here and quartiles here.
Following the categorization, locations of the counties in each category were mapped and the total vote share of each county was calculated (meaning the sum of ALL Republican OR Democratic votes across election years divided by the sum of ALL Republican AND Democratic votes across election years). A line graph of vote share for each election year by category was also created following the same logic, except ALL the results of the first operation were summed by election-year to get a category-wide number.
This dashboard was created by using Quarto in R. Quarto allows for R/Python (and many more) users to build Websites, Books, Dashboards, and many other web-based tools. Visit Quarto to learn more about how to build different types of content.
In addition to Quarto, the following R packages were used:
Kunst, J. (2022). Highcharter: A wrapper for the ‘Highcharts’ library. (Version 0.9.4) [R package]. CRAN. https://CRAN.R-project.org/package=highcharter
Pebesma, E. (2024). Sf: Simple Features for R. (Version 1.0-18) [R package]. CRAN. https://CRAN.R-project.org/package=sf
Wickham, H. (2023). Tidyverse: Easily Install and Load the ‘Tidyverse’ . (Version 2.0.0) [R package]. CRAN. https://CRAN.R-project.org/package=tidyverse
Ooms, J. (2024). Jsonlite: A Simple and Robust JSON Parser and Generator for R. (Version 1.8.9) [R package]. CRAN. https://CRAN.R-project.org/package=jsonlite
Mahoney, M. (2023). Geojsonio: Convert Data from and to ‘GeoJSON’ or ‘TopoJSON’ . (Version 0.11.3) [R package]. CRAN. https://CRAN.R-project.org/package=geojsonio
Couch, S. (2024). Broom: Convert Statistical Objects into Tidy Tibbles. (Version 1.0.7) [R package]. CRAN. https://CRAN.R-project.org/package=broom
Algara, Carlos; Sharif Amlani, 2021, “Replication Data for: Partisanship & Nationalization in American Elections: Evidence from Presidential, Senatorial, & Gubernatorial Elections in the U.S. Counties, 1872-2020”, https://doi.org/10.7910/DVN/DGUMFI, Harvard Dataverse, V1; dataverse_shareable_gubernatorial_county_returns_1865_2020.Rdata [fileName]
U.S. Census Bureau. (2010). gz_2010_us_050_00_5m.zip [Cartographic Boundary Files - Shapefile]. U.S. Census Bureau. https://www.census.gov/geographies/mapping-files/time-series/geo/carto-boundary-file.2010.html#list-tab-1556094155
**In addition to R, Quarto, and the above packages, HTML, Javascript, and CSS were used to create a svg that serves as the legend in the map.
If you have any questions or are interested in learning about how the dashboard was created, please contact Lauren Gerber or visit the Github for the code you can use to reproduce the dashboard.
For other questions about QoG Data, please contact here.