Description Usage Arguments Value Author(s) References Examples
This function is a wrapper for the District.getByOfficeState() method of the PVS API District class which grabs district IDs according to the office and state. The function sends a request with this method to the PVS API for all district names and office IDs given as a function input, extracts the XML values from the returned XML file(s) and returns them arranged in one data frame.
1 | District.getByOfficeState(officeId, stateId, districtName=NULL, all=FALSE)
|
officeId |
a character string or list of character strings with the office ID(s) (see references for details) |
stateId |
a character string or list of character strings with the state ID(s) (see references for details) |
districtName |
(optional) a character string or list of character strings with the district name (default: All) |
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) |
A data frame with a row for each district and columns with
the following variables describing the district:
districtList.district*.districtId,
districtList.district*.name,
districtList.district*.officeId,
districtList.district*.stateId.
Ulrich Matter <ulrich.matter-at-unibas.ch>
http://api.votesmart.org/docs/District.html
See
http://api.votesmart.org/docs/semi-static.html for a list
of office IDs or use Office.getOfficesByType(),
Office.getOfficesByLevel(), Office.getOfficesByTypeLevel()
or Office.getOfficesByBranchLevel().
Use
State.getStateIDs() to get a list of state IDs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # First, make sure your personal PVS API key is saved as character string in the pvs.key variable:
## Not run: pvs.key <- "yourkey"
# get districts for certain office and state IDs
## Not run: districts <- District.getByOfficeState(officeId=list(8,9),stateId=list("NY","NJ"))
## Not run: district
# get a data frame of districts according to all state/office/districtName combinations
## Not run: districts <- District.getByOfficeState(officeId=list(8,9),stateId=list("NY","NJ"),
districtName=list(1,2), all=TRUE)
## End(Not run)
## Not run: districts
# get a data frame of districts according to the exact state/office/districtName combinations
# (i.e., 8/"NY"/1, 9/"NJ"/2)
## Not run: districts <- District.getByOfficeState(officeId=list(8,9),stateId=list("NY","NJ"),
districtName=list(1,2), all=FALSE)
## End(Not run)
## Not run: districts
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.