Description Usage Arguments Value Author(s) References Examples
This function is a wrapper for the Candidates.getByLevenshtein() method of the PVS API Candidates class which grabs a list of candidates according to an approximate lastname match. The function sends a request with this method to the PVS API for all last names and election years given as a function input, extracts the XML values from the returned XML file(s) and returns them arranged in one data frame.
1 | Candidates.getByLevenshtein(lastName, electionYear=NULL)
|
lastName |
a character string or list of character strings with the last name(s) (see references for details) |
electionYear |
(optional) a character string or list of character strings with the election year(s) (default: >= current year) |
A data frame with a row for each candidate and year and
columns with the following variables describing the
candidate:
candidateList.candidate*.candidateId,
candidateList.candidate*.firstName,
candidateList.candidate*.nickName,
candidateList.candidate*.middleName,
candidateList.candidate*.preferredName,
candidateList.candidate*.lastName,
candidateList.candidate*.suffix,
candidateList.candidate*.title,
candidateList.candidate*.ballotName,
candidateList.candidate*.electionParties,
candidateList.candidate*.electionStatus,
candidateList.candidate*.electionStage,
candidateList.candidate*.electionDistrictId,
candidateList.candidate*.electionDistrictName,
candidateList.candidate*.electionOffice,
candidateList.candidate*.electionOfficeId,
candidateList.candidate*.electionStateId,
candidateList.candidate*.electionOfficeTypeId,
candidateList.candidate*.electionYear,
candidateList.candidate*.electionSpecial,
candidateList.candidate*.electionDate,
candidateList.candidate*.officeParties,
candidateList.candidate*.officeStatus,
candidateList.candidate*.officeDistrictId,
candidateList.candidate*.officeDistrictName,
candidateList.candidate*.officeStateId,
candidateList.candidate*.officeId,
candidateList.candidate*.officeName,
candidateList.candidate*.officeTypeId,
candidateList.candidate*.runningMateId,
candidateList.candidate*.runningMateName.
Ulrich Matter <ulrich.matter-at-unibas.ch>
http://api.votesmart.org/docs/Candidates.html
Use
CandidateBio.getBio(), Candidates.getByOfficeState(),
Candidates.getByOfficeTypeState(),
Candidates.getByElection(), Candidates.getByDistrict(),
Candidates.getByZip(), Committee.getCommitteeMembers(),
Election.getStageCandidates(), Leadership.getOfficials(),
Local.getOfficials(), Officials.getStatewide(),
Officials.getByOfficeState(),
Officials.getByOfficeTypeState(), Officials.getByDistrict()
or Officials.getByZip() to get last name(s).
1 2 3 4 5 | # First, make sure your personal PVS API key is saved as character string in the pvs.key variable:
## Not run: pvs.key <- "yourkey"
# get candidates with similar last names
## Not run: names <- Candidates.getByLevenshtein(list("Obama","Romney"),2012)
## Not run: names
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.