Build Status CRAN status Monthly Downloads Weekly Downloads Total Downloads Dev: v0.1.3

A R package for acquiring and analyzing political data — including polls, election results, legislator information, and demographic data.

Author: G. Elliott Morris

For more, visit the package documentation website here, especially the the vignette.

For even more, see the package’s project description my blog or view the vignettes (vignettes area work in progress). You can find many examples of how these data are used in the real world via my interactive R course at, “Analyzing Election and Polling Data in R”.

For even even more, I’m in the process of writing a detailed guide on using R for analyzing political data, Analyzing Political Data in R , that uses many of the functions and datasets from this package. The example use cases extend beyond those in the function documentation and this readme.


Install the politicaldata package from CRAN:

As the landscape of online data and API calls is constantly changing, the development version is likely to contain quicker bug fixes and integration of new data. You can instill the dev version using the remotes::install_github() workflow outlined here:

To get the current development version from GitHub:


This package provides a variety of functions for quickly accessing different data sources used in political science and analytics. For example, you can download a data.frame of the DW-NOMINATE scores of congressional ideology computed by the VoteView project at UCLA:

A list of functions:

  • get_house_nominate() returns DW-NOMINATE ideology scores for each member of the U.S. House of Representatives for a specified congress, else every Representative ever.
  • get_senate_nominate() returns DW-NOMINATE ideology scores for each member of the U.S. Senate for a specified congress, else every Senator ever.
  • trump_approval_polls_538() returns a dataset of approval polls aggregated by the folks over at FiveThirtyEight.
  • get_cap_mip() returns a historical dataset of the aggregated responses to Gallup’s Most Important Problem questions, coded by major topic. Part of a suite of functions for obtaining data from the Comparative Agendas Project.

A list of datasets:

  • house_116 is a saved copy of the output from get_house_nominate(congress=116) run on the last day the package was updated (and thus should only be used for demos, unless you want outdated data).
  • senate_116 is the same as the above, bur for the Senate. Downloaded via get_senate_nominate(congress=116).
  • us_polls_history is a dataset of US presidential election polling from the 1980 through 2016 elections.
  • house_results is a dataset of results for elections to the US House of Representatives that occurred from 1976 to 2018
  • pres_results_by_cd is a dataset of results for presidential elections broken down by congressional district from 1990 to 2016


There are vignettes. They are in the package documentation. You can see them online in this repository or the docs website.


You should feel free to suggest more data and/or functions to add, open issues, submit pull requests, etc.


You can reach me by opening an issue, on Twitter, or via email (but I’d prefer you to communicate primarily via GitHub).


This package is open source and released under the MIT License, which only stipulates that you must distribute the License alongside the package. For more details, click on “See License” at the top right of the repository.