Learn R Programming

pvsR (version 0.1.1)

Rating.getRating: Get all candidate ratings from an evaluation by a special interest group

Description

This function is a wrapper for the Rating.getRating() method of the PVS API Rating class which dumps all candidate ratings from a scorecard by a special interest group (SIG). The function sends a request with this method to the PVS API for all rating 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

Rating.getRating(ratingId)

Arguments

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

Value

  • A data frame with a row for each candidate and columns with variables describing the candidate. The returned data frame contains a row for each candidate and columns with the following variables describing the candidate: candidateRating*.candidateId, candidateRating*.rating.

References

http://api.votesmart.org/docs/Rating.html Use Rating.getSigRatings() or Rating.getCandidateRating() to get a list of rating 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 the candidate rating by a certain special interest group
scorecard <- Rating.getRating(77)
scorecard

Run the code above in your browser using DataLab