Type: | Package |
Title: | Load Associated Press Election Results with Elex |
Version: | 1.0 |
Date: | 2016-02-02 |
Author: | Geoff Hing |
Maintainer: | Geoff Hing <geoffhing@gmail.com> |
Description: | Provides R access to election results data. Wraps elex (https://github.com/newsdev/elex/), a Python package and command line tool for fetching and parsing Associated Press election results. |
License: | MIT + file LICENSE |
Imports: | utils |
SystemRequirements: | Python (>= 2.7 or >= 3.5) and elex package |
RoxygenNote: | 5.0.1 |
NeedsCompilation: | no |
Packaged: | 2016-02-04 12:19:20 UTC; ghing |
Repository: | CRAN |
Date/Publication: | 2016-02-04 15:11:37 |
Load Associated Press Election Results with Elex
Description
Provides R access to election results data. Wraps elex (https://github.com/newsdev/elex/), a Python package and command line tool for fetching and parsing Associated Press election results.
Details
A light R wrapper around the elex command
elexr provides an R interface for the elex package (http://github.com/newsdev/elex/) to load election results from the Associated Press Elections API.
Rather than reinventing the wheel, this package simply runs elex
in
a shell and loads the CSV output into a data frame. Because of this,
you'll need Python and to install elex by following the instructions at
http://elex.readthedocs.org/en/latest/install.html.
You'll also need an API key for the API Elections API. You'll need to set
the AP_API_KEY
environtment variable in your R session to be able to
retreive results.
Examples
library(elexr)
# Set your actual AP Elections API Key here. The string below is an example
# only and won't work.
Sys.setenv(AP_API_KEY = "AZA0AZ0aZ0ZA0az0AzAZ0AzazAzaZaZAZ")
tryCatch({
ia_results <- results("02-01-2016")
},
error = function(err) {
print(err)
})
Fetch election results
Description
Fetch election results
Usage
results(election_date)
Arguments
election_date |
Election date as a string in MM-DD-YYYY format. |