getAllLocalOfficials: Fetch data on all local (city- or county-) officials

Description Usage Arguments Details Value Author(s) References Examples

View source: R/getAllLocalOfficials.R

Description

This function is essentially a wrapper around Local.getOfficials().

Usage

1
2
getAllLocalOfficials(locality="counties", batchsize=50,
 pause=0, backupfile="locofs.list.Rdata")

Arguments

locality

a character string indicating whether data on county-officials ("counties") or city-officials ("cities") should be downloaded.

batchsize

numerical, indicating the number of requests that should be processed in one batch (defaults to 50).

pause

numerical, indicating how long (in seconds) the download process should be paused after each batch (defaults to 0)

backupfile

character string for the path/file-name of the Rdata-file where the data should be saved (batch-wise) during the download process (default: "locofs.list.Rdata").

Details

This functions splits large requests into several batches. The requests are then processed batch-wise and are saved on the local disc to make sure that not too much RAM is assigned to the pvsR task.

Value

A data frame with 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.

Author(s)

Ulrich Matter <ulrich.matter-at-unibas.ch>

References

http://api.votesmart.org/docs/Local.html
Use Local.getCounties() or Local.getCities() to get a list of local IDs.
See also: Matter U, Stutzer A (2015) pvsR: An Open Source Interface to Big Data on the American Political Sphere. PLoS ONE 10(7): e0130501. doi: 10.1371/journal.pone.0130501

Examples

1
2
3
4
5
6
# First, make sure your personal PVS API key is saved as an option
# (options("pvs.key" = "yourkey")) or in the pvs.key variable:
## Not run: pvs.key <- "yourkey"
# get a list of all local officials
## Not run: all_countyofficials <- getAllLocalOfficials()
## Not run: head(officials)

umatter/pvsR documentation built on Jan. 9, 2021, 4:35 p.m.