Learn R Programming

pvsR (version 0.1.1)

Local.getOfficials: Get officials for a locality

Description

This function is a wrapper for the Local.getOfficials() method of the PVS API Local class which returns a list of officials in a locality. The function sends a request with this method to the PVS API for all local 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

Local.getOfficials(localId)

Arguments

localId
a character string or list of character strings with the local ID(s) (see references for details)

Value

  • A data frame with a row for each official and columns with the following variables describing the official. The returned data frame contains a row for each official and columns with the following variables describing the official: candidatelist.candidate*.candidateId, candidatelist.candidate*.firstName, candidatelist.candidate*.nickName, candidatelist.candidate*.middleName, candidatelist.candidate*.lastName, candidatelist.candidate*.suffix, candidatelist.candidate*.title, candidatelist.candidate*.electionParties, candidatelist.candidate*.electionDistrictId, candidatelist.candidate*.electionStateId, candidatelist.candidate*.officeParties, candidatelist.candidate*.officeDistrictId, candidatelist.candidate*.officeDistrictName, candidatelist.candidate*.officeStateId, candidatelist.candidate*.officeId, candidatelist.candidate*.officeName, candidatelist.candidate*.officeTypeId.

References

http://api.votesmart.org/docs/Local.html Use Local.getCounties() or Local.getCities() to get a list of local 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 list of officials according to certain local IDs
officials <- Local.getOfficials(list(3200,3203))
officials

Run the code above in your browser using DataLab