12.11 Additional resources

If you’re working with large data files, you may want to look into alternatives to base R’s save() and load() functions. Several packages aim to make it faster to store and load R objects, including fst and feather (feather is also useful for those who know Python as well as R, since that binary file format can be read by both languages). Check out the packages on CRAN for more information.

For analyzing and visualizing pre-election polling data in R, the pollstR package is an R client for the Huffington Post’s Pollster API. This source has mostly data on U.S. contests, although it occasionally includes data from other major elections worldwide, such as the 2017 France presidential race. https://github.com/rOpenGov/pollstR

Heat maps can be an interesting way to visualize changes in results over time. Peter Aldhous, a science reporter with BuzzFeed News and investigative reporting instructor at the University of California Santa Cruz, posted materials from his National Institute for Computer-Assisted Reporting training session that includes creating a heat map with ggplot2. http://paldhous.github.io/NICAR/2017/r-analysis.html

Interested in visualizing election results by party for a legislature such as the U.S. Senate or U.K. House of Commons? Check out the ggparliament package on GitHub at https://github.com/robwhickman/ggparliament

My guide to Election Night resources for the 2016 election includes a link to compare forecasts with results, and how to use the pollstR package to pull data from the Huffington Post’s Pollster API. http://www.computerworld.com/article/3139884/data-analytics/r-resources-for-election-night.html

Kan Nishida has a more stats-heavy example of using R to analyze election results, using techniques such as K-means clustering to see which California counties are most similar to each other based on 2016 election results. bit.ly/Rsimilarities.