Learn R Programming

pvsR (version 0.1.1)

Leadership.getOfficials: Get officials that hold the leadership role in certain states

Description

This function is a wrapper for the Leadership.getOfficials() method of the PVS API Leadership class which grabs a list of officials that hold the leadership role in certain states. The function sends a request with this method to the PVS API for all state and leadership 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

Leadership.getOfficials(stateId="NA", leadershipId)

Arguments

stateId
(optional) a character string or list of character strings with the state ID(s) (default: NA) (see references for details)
leadershipId
a character string or list of character strings with the leadership ID(s) (see references for details)

Value

  • A data frame with a row for each leadership position and columns with variables describing the official. The returned data frame contains a row for each leadership position and columns with the following variables describing the official: leaders.leader*.candidateId, leaders.leader*.firstName, leaders.leader*.middleName, leaders.leader*.lastName, leaders.leader*.suffix, leaders.leader*.position, leaders.leader*.officeId, leaders.leader*.title.

References

http://api.votesmart.org/docs/Leadership.html Use State.getStateIDs() to get a list of state IDs. Use Leadership.getPositions() to get a list of leadership 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 leaders by state ID and leadership ID
officials <- Leadership.getOfficials(list("NY","FL"),list(138,140))
officials

Run the code above in your browser using DataLab