Learn R Programming

pollstR (version 1.4.0)

pollster_chart: Return a single chart

Description

Return a single chart. This includes both current and historical estimates by date.

Usage

pollster_chart(slug, convert = TRUE)
pollstr_chart(slug, convert = TRUE)

Arguments

slug
The slug-name of the chart to be returned.
convert
Rearrange the data returned by the API into easier to use data frames.

Value

If convert=TRUE, then a "pollster_chart" object with elements
  • id ID number of the chart.
  • title Title of the chart.
  • slug Slug (URL-friendly title) of the chart.
  • topic Topic of the chart.
  • state State of the chart, if it relates to a state.
  • short_title Short title of the chart.
  • election_date Election date, if the chart relates to an election).
  • poll_count Number of polls in the chart.
  • last_updated Time the chart was last updated.
  • url URL of the chart.
  • estimates A data frame with an observation for each choice and the current estimates.
  • estimates_by_date A data frame with an observation for each choice at each date, with estimates.
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: 
# chart <- pollster_chart('2016-general-election-trump-vs-clinton')
# chart
# ## End(Not run)

Run the code above in your browser using DataLab