Home

Awesome

<!-- README.md is generated from README.Rmd. Please edit that file -->

politicaldata

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 DataCamp.com, “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.

Installation

Install the politicaldata package from CRAN:

# install politicaldata from CRAN
install.packages('politicaldata')

# load the politicaldata package
library(politicaldata)

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:

# install the remotes package if it's not already
if (!requireNamespace("remotes", quietly = TRUE)) {
  install.packages("remotes")
}

# install dev version of politicaldata from github
remotes::install_github("elliottmorris/politicaldata")

# load the politicaldata package
library(politicaldata)

Usage

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:

# import the package
library(politicaldata)

# download the NOMINATE scores for the 116th House
house_ideo <- get_house_nominate(congress = 116)

# download the NOMINATE scores for the Senate in the 116th Congress
senate_ideo <- get_senate_nominate(congress = 116)

# take a look with dplyr::head()
suppressMessages(library(dplyr))

head(house_ideo[1:5])
#>   congress chamber icpsr state_icpsr district_code
#> 1      116   House 20301          41             3
#> 2      116   House 21102          41             7
#> 3      116   House 21192          41             2
#> 4      116   House 21193          41             5
#> 5      116   House 21376          41             1
#> 6      116   House 21500          41             6

A list of functions:

A list of datasets:

Vignettes

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

Suggested related packages:

Contributions

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

Contact

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

License

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.