Learn R Programming

pollstR (version 1.4.0)

pollster_charts: Get list of available charts

Description

Get list of available charts

Usage

pollster_charts(page = 1, topic = NULL, state = NULL, showall = NULL, convert = TRUE, max_pages = 1)
pollstr_charts(page = 1, topic = NULL, state = NULL, showall = NULL, convert = TRUE, max_pages = 1)

Arguments

page
Page to get. The API returns results in pages of 100.
topic
Only include charts related to a specific topic. See http://elections.huffingtonpost.com/pollster/api for examples.
state
Only include charts from a single state. Use 2-letter state abbreviations. "US" will return all national charts.
showall
logical Include charts for races that were once possible but didn't happen (e.g. Gingrich vs. Obama 2012)
convert
Rearrange the data returned by the API into easier to use data frames.
max_pages
Maximum number of pages to get.

Value

If convert=TRUE, a "pollster_charts" object with elements
Otherwise, a "list" in the original structure of the json returned by the API.

References

http://elections.huffingtonpost.com/pollster/api

Examples

Run this code
## Not run: 
#  # Get charts related to Washington
#  pollster_charts(state = 'WA')
#  # Get national charts
#  pollster_charts(state='US')
#  # Get charts for the topic '2016-president'
#  pollster_charts(topic = '2016-president')
#  # Get all charts
#  pollster_charts()
#  # By default, this only returns the first 100 charts, to get more
#  # set max_pages higher. Use Inf, to ensure you get all.
#  pollster_charts(topic = '2016-president', max_pages = Inf)
# ## End(Not run)

Run the code above in your browser using DataLab