Learn R Programming

pollstR (version 1.2.0)

pollstr_polls: Get a list of polls

Description

Get a list of polls

Usage

pollstr_polls(page = 1, chart = NULL, state = NULL, topic = NULL,
  before = NULL, after = NULL, sort = FALSE, showall = NULL,
  max_pages = 1, convert = TRUE)

Arguments

page
Return page number
chart
List polls related to the specified chart. Chart names are the slug returned by pollstr_charts.
state
Only include charts from a single state. Use 2-letter pstate abbreviations. "US" will return all national charts.
topic
Only include charts related to a specific topic. See the http://elections.huffingtonpost.com/pollster/api for examples.
before
Only list polls that ended on or bfore the specified date.
after
Only list polls that ended on or bfore the specified date.
sort
If TRUE, then sort polls by the last updated time.
showall
Include polls for races that were once possible but didn't happen (e.g. Gingrich vs. Obama 2012)
max_pages
Maximum number of pages to get.
convert
Rearrange the data returned by the API into easier to use data frames.

Value

  • If convert=TRUE, a "pollstr_polls" object with elements [object Object],[object Object],[object Object],[object Object] 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
# Get polls related to a chart pulled programmatically with
# pollstr_charts()
all_charts <- pollstr_charts()
pollstr_polls(chart=all_charts$slug[1])
# Lookup polls related to a specific topic
pollstr_polls(topic='2016-president')

Run the code above in your browser using DataLab