Learn R Programming

pvsR (version 0.1.1)

Committee.getCommitteesByTypeState: Get a list of committees according to type and state

Description

This function is a wrapper for the Committee.getCommitteesByTypeState() method of the PVS API Committee class which returns a list of committees for each type in each requested state. The function sends a request with this method to the PVS API for all type and state 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

Committee.getCommitteesByTypeState(typeId=list("H","S","J"),
    stateId="NA", all=FALSE)

Arguments

typeId
(optional) a character string or list of character strings with the type ID(s) (default: All) (see references for details)
stateId
(optional) a character string or list of character strings with the state ID(s) (default: NA) (see references for details)
all
a logical indicator; if TRUE data on all possible combinations of the input variables are returned, if FALSE (default) only the exact combinations of them (see example)

Value

  • A data frame with a row for each committee and columns with variables describing the committee. The returned data frame contains a row for each committee and columns with the following variables describing the committee: committees.committee*.committeeId, committees.committee*.parentId, committees.committee*.stateId, committees.committee*.committeeTypeId, committees.committee*.name.

References

http://api.votesmart.org/docs/Committee.html|cr See http://api.votesmart.org/docs/semi-static.html for a list of committee-type ID(s). Use State.getStateIDs() to get a list of state 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 a data frame of committees according to all type/state combinations
committees <- Committee.getCommitteesByTypeState(typeId=list("H","S"),
stateId=list("NY","NJ"), all=TRUE)
committees
# get a data frame of committees according to the exact type/state combinations
# (i.e., "H"/"NY", "S"/"NJ")
committees <- Committee.getCommitteesByTypeState(typeId=list("H","S"),
stateId=list("NY","NJ"), all=FALSE)
committees

Run the code above in your browser using DataLab