knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

Rvoteview

Travis-CI Build Status AppVeyor Build status

WARNING: This package is under construction. Please be patient and leave issues here on Github or contact Luke Sonnet with any questions.

This is a package that enables you to query the Voteview database for roll calls and work with data frames or a pscl rollcall object.

To install this package, run the following (note you have to have devtools installed first):

# install.packages('devtools')
devtools::install_github("voteview/Rvoteview")

For more thorough documentation, see the help files for individual functions and the vignette at this link here.

Quick Start: Using Rvoteview

To use Rvoteview, you generally want to search the database to get a list of vote ids and then use those to return the individual votes. We query the database with a search term and some parameters to constrain the search. The default behavior is to search any words as key words, returning the roll calls that best match any key words you enter. Again, there are further examples in the vignette.

So let's start with a search for roll calls with the key word "Iraq".

library(Rvoteview)

res <- voteview_search("Iraq")
names(res)

## I will drop description since it is a very long field
res[1:5, 1:5]

Using res$id we can get a rollcall object (from the pscl package) that contains the full set of votes and data for each roll call.

## Get a rollcall object using the ids, please limit to a few ids for now!
rc <- voteview_download(res$id[1:10])
## Now this object can be used in many 'pscl' methods
summary(rc)

You also have lots of metadata on roll calls and legislators in various data frames. For example, we can see some legislator metadata:

rc$legis.long.dynamic[1:5, 1:5]

You can also search by start and end date, congress, and chamber. Please see the help files for each function after you install the package to see a little more about how they work.

## Voteview search with options
res <- voteview_search(
  "Iraq", 
  chamber = "House",
  congress = 110:112,
  enddate = "2013-04-20"
  )
res[1:5, 1:5]

We can print out the exact query that the function builds using all of these arguments by retrieving the 'qstring' attribute of the returned data frame:

attr(res, "qstring")

We can assemble and use these complex queries ourselves. Here's one example where we look for all roll calls with the key words "estate", "death", or "tax" and was held in the 100th to the 114th Congress.

## Voteview search with options
res <- voteview_search("(alltext:estate death tax congress:[100 to 114])")
res[1:5, 1:5]

You can also search for member data using the member_search function.

res <- member_search("Paul", state = "KY")

res[1:5, 1:5]


JeffreyBLewis/Rvoteview documentation built on Oct. 15, 2019, 10:18 p.m.