Description Usage Format Source Examples
Scraped from FiveThirtyEight's website of most recent polls on July 28 2020.
1 |
A tibble with 5312 rows and 37 columns
numeric
numeric
numeric
character
numeric
character
numeric
character
character
numeric
character
character
numeric
character
character
character
character
numeric
logical
Date
Date
Date
character
logical
character
logical
logical
logical
character
character
character
character
numeric
character
character
character
numeric
https://projects.fivethirtyeight.com/polls-page/president_polls.csv
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | library(ggplot2)
library(dplyr)
data(presidential_polls)
presidential_polls %>%
filter(candidate_party %in% c("DEM", "REP")) %>%
filter(!is.na(state)) %>%
ggplot(aes(x = end_date, y = pct)) +
geom_point(aes(colour = candidate_party)) +
facet_wrap(~state) +
scale_colour_party()
# national polls
presidential_polls %>%
filter(candidate_party %in% c("DEM", "REP")) %>%
filter(answer %in% c("Biden", "Trump")) %>%
filter(is.na(state)) %>%
ggplot(aes(x = end_date, y = pct,
colour = candidate_party)) +
geom_point(alpha = 0.3) +
geom_smooth(se = FALSE, method="gam") +
scale_colour_party() +
theme(legend.position="bottom")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.