voteview_search: Query the Voteview Database for Roll Calls

Description Usage Arguments Details Value See Also Examples

View source: R/search.R

Description

Searches the Voteview database for roll calls and returns a data frame with bill IDs, the breakdown of voting, and other descriptive information. Takes any one or more of the arguments. See the GitHub Wiki here for more complete documentation.

Usage

1
2
3
voteview_search(q = NULL, startdate = NULL, enddate = NULL,
  congress = NULL, chamber = NULL, maxsupport = NULL, minsupport = NULL,
  keyvote = NULL)

Arguments

q

A string that is passed directly to the Voteview query parser. It can either specify parameters for the search, incorporate complex boolean logic, or be a simple string that will search all text fields. See Details.

startdate

A string of the format "yyyy-mm-dd" that is the earliest possible date to search for a roll call.

enddate

A string of the format "yyyy-mm-dd" that is the latest possible date to search for a roll call.

congress

A numeric vector of the congresses to constrain the search to. The default NULL value returns results from all congresses.

chamber

A string in c("House", "Senate"). The default NULL value returns results from both chambers of congress.

maxsupport

Support is the share of Yea votes over total Yea and Nay votes. maxsupport is a number specifying the maximum support allowed for returned votes.

minsupport

A number specifying the minimum support allowed for returned votes.

keyvote

A string or boolean indicating the type of key vote to search for (e.g. 'CQ") or whether to search for any key vote (e.g. T).

Details

This function requires at least one argument. The user can use the q field either to search across all text fields or to pass a more complicated advanced query. This is essentially like a "search box" where the user can just put in some key words, specific phrases in quotes, or can use notation like "support:[10 to 90]" along with boolean logic to build complicated queries.

Complete documentation for the query syntax can be found at the GitHub Wiki here. You can also see the vignette for other examples. In general, the following syntax is used, field:specific phrase (field:other phrase OR field:second phrase). For example, if you wanted to find votes with "war" and either "iraq" or "afghanistan" in any text field, you could set the query to be "alltext:war AND (alltext:iraq OR alltext:afghanistan)". Note that the AND in the above is redundant as fields are joined by AND by default. Numeric fields can be searched in a similar way, although users can also use square brackets and "to" for ranges of numbers. For example, the query for all votes about taxes in the 100th to 102nd congress could be expressed either using "alltext:taxes congress:100 OR congress:101 OR congress:102" or using "alltext:taxes congress:[100 to 102]". Furthermore, users can specify exact phrases that they want to search like "description:'estate tax'".

The fields that can be searched with text are codes, codes.Clausen, codes.Peltzman, codes.Issue, description, shortdescription, bill, and alltext. The code and bill fields are searched exactly using regular expressions while in the other fields words are stemmed and searched anywhere in the field specified (unless the query is in quotes). The fields that can be searched numerically are congress, yea, nay, and support. Users can also search for stashed votes using the saved field. Searching by individual legislator will be implemented soon.

Value

A data.frame with the following columns, if the fields are available in the database:

See Also

'voteview_download'.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Search for example roll calls
res <- voteview_search("Iraq")
res

## Return exact string used in search
attr(res, "qstring")

## Not run: 
## Search for votes with a start date
res <- voteview_search("Iraq", startdate = "2005-01-01")
 
## Search for votes with an end date in just the house
res <- voteview_search("Iraq", enddate = "2005-01-01", chamber = "House")

## Search for votes with a start date in just the house in the 110th or 112th congress
res <- voteview_search("Iraq", startdate = "2005-01-01", congress = c(110, 112), chamber = "House")

## Search for "war on terror" AND iraq
res <- voteview_search("description:'war on terror' alltext:iraq")


## End(Not run)

voteview/Rvoteview documentation built on May 1, 2018, 12:24 a.m.