Learn R Programming

pvsR (version 0.1.1)

Votes.getBill: Get general information on a bill

Description

This function is a wrapper for the Votes.getBill() method of the PVS API Votes class which grabs the general information on a bill. The function sends a request with this method to the PVS API for all bill IDs given as a function input, extracts the XML values from the returned XML file(s) and returns them arranged in one data frame.

Usage

Votes.getBill(billId,...)

Arguments

billId
a character string or list of character strings with the bill ID(s) (see references for details)
...
further arguments that are passed on to internal functions. Currently the argument separate can be defined: separate is a vector of character strings defining subnodes that should be returned separately (e.g., "sponsors").

Value

  • If separate is not specified, a data frame with a row for each bill and columns with variables describing the bill. If separate is specified, a list containing several data frames, one for each subnode mentioned in separate and additionally one data frame containing all remaining nodes not mentioned in separate. The returned data frame contains a row for each bill and columns with the following variables describing the bill: bill.billnumber, bill.parentbill, bill.title, bill.officialtitle, bill.dateintroduced, bill.type, bill.categories.category*.categoryId, bill.categories.category*.name, bill.billtextLink, bill.sponsors.sponsor*.candidateId, bill.sponsors.sponsor*.name, bill.sponsors.sponsor*.type, bill.committeeSponsors.committeeSponsor*.committeeId, bill.committeeSponsors.committeeSponsor*.name, bill.actions.action*.actionId, bill.actions.action*.level, bill.actions.action*.stage, bill.actions.action*.outcome, bill.actions.action*.statusDate, bill.actions.action*.rollNumber, bill.actions.action*.yea, bill.actions.action*.nay, bill.actions.action*.voiceVote, bill.amendments.amendment*.billNumber, bill.amendments.amendment*.actionId, bill.amendments.amendment*.title, bill.amendments.amendment*.statusDate.

References

http://api.votesmart.org/docs/Votes.html Use Votes.getByBillNumber(), Votes.getBillsByCategoryYearState(), Votes.getBillsByYearState(), Votes.getBillsByOfficialYearOffice(), Votes.getBillsByOfficialCategoryOffice(), Votes.getByOfficial(), Votes.getBillsBySponsorYear(), Votes.getBillsBySponsorCategory() or Votes.getBillsByStateRecent() to get a list of bill IDs.

Examples

Run this code
# First, make sure your personal PVS API key is saved as character string in the pvs.key variable:
pvs.key <- "yourkey"
# get information about certain bills
billinfo <- Votes.getBill(list(2819,6427))
billinfo
# let some variables with subnodes be returned separately (here: "sponsors" and "actions")
billinfo2 <- Votes.getBill(billId=list(2819,6427,6590),
separate=c("sponsors","actions"))
billinfo2
# check the sponsors of the requested bill (argument of separate)...
billinfo2$sponsors
# ... and the usual variables describing the bill (nodes not mentioned in separate)
billinfo2$main

Run the code above in your browser using DataLab