Last active
September 16, 2015 03:49
-
-
Save jonrobinson2/28af8c1606e027501cf5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(pollstR) | |
require(ggplot2) | |
require(magrittr) | |
remove(list=ls()) | |
tmp=pollstr_polls(max_pages = 10000, chart = '2016-national-gop-primary', after = "2015-3-1") | |
tmp$questions=tmp$questions[tmp$questions$topic=='2016-president-gop-primary',] | |
tmp1=merge(tmp$polls, tmp$questions, by='id') | |
tmp1$interviewer="No Interviewer" | |
tmp1$interviewer[tmp1$method %in% c('Live Phone','IVR/Live Phone')]="Interviewer" | |
plt=tmp1[tmp1$choice %in% c('Trump') ,] %>% | |
ggplot(aes(start_date,value)) + | |
geom_point(aes(size=observations, colour=interviewer)) + | |
geom_smooth(aes(weight=observations, colour=interviewer), size=3, level=.9, alpha=.1) + | |
scale_size(guide=FALSE) + | |
scale_colour_brewer("Methodology",palette = "Paired") + | |
theme(panel.background = element_rect(fill = NA, colour = "black", size = 0.25), | |
panel.border = element_blank(), | |
panel.grid.major = element_line(colour = "black", size = 0.05), | |
panel.grid.minor = element_line(colour = "black", size = 0.05), | |
plot.title=element_text(size=18, family="Helvetica Neue Light"), | |
axis.title.x=element_text(size=14, family="Helvetica Neue Light"), | |
axis.text.x=element_text(colour="black", size=14, family="Helvetica Neue Light"), | |
axis.title.y=element_text(size=14, family="Helvetica Neue Light"), | |
axis.text.y=element_text(colour="black",size=14, family="Helvetica Neue Light"), | |
strip.text.x = element_text(size = 14,family="Helvetica Neue Light"), | |
strip.text.y = element_text(size = 14,family="Helvetica Neue Light"), | |
legend.title = element_text(size=14, family="Helvetica",face="bold"), | |
legend.text = element_text(size=14, family="Helvetica Neue Light"), | |
strip.background = element_rect(colour = "grey", fill = "white")) + | |
xlab("Date") + ylab("%") + ggtitle("Trump Vote by Whether the Poll Has An Interviewer") | |
print(plt) | |
devtools::session_info() | |
#Session info ----------------------------------------------------------------------- | |
# setting value | |
# version R version 3.2.0 (2015-04-16) | |
# system x86_64, darwin13.4.0 | |
# ui RStudio (0.99.467) | |
# language (EN) | |
# collate en_US.UTF-8 | |
# tz America/New_York | |
#Packages --------------------------------------------------------------------------- | |
# package * version date source | |
# bitops * 1.0-6 2013-08-17 CRAN (R 3.2.0) | |
# colorspace * 1.2-6 2015-03-11 CRAN (R 3.2.0) | |
# devtools * 1.7.0 2015-01-17 CRAN (R 3.2.0) | |
# digest * 0.6.8 2014-12-31 CRAN (R 3.2.0) | |
# ggplot2 1.0.1 2015-03-17 CRAN (R 3.2.0) | |
# gtable * 0.1.2 2012-12-05 CRAN (R 3.2.0) | |
# httr * 0.6.1 2015-01-01 CRAN (R 3.2.0) | |
# jsonlite * 0.9.16 2015-04-11 CRAN (R 3.2.0) | |
# labeling * 0.3 2014-08-23 CRAN (R 3.2.0) | |
# magrittr 1.5 2014-11-22 CRAN (R 3.2.0) | |
# MASS * 7.3-40 2015-03-21 CRAN (R 3.2.0) | |
# munsell * 0.4.2 2013-07-11 CRAN (R 3.2.0) | |
# plyr * 1.8.2 2015-04-21 CRAN (R 3.2.0) | |
# pollstR 1.2.0 2015-03-09 CRAN (R 3.2.0) | |
# proto * 0.3-10 2012-12-22 CRAN (R 3.2.0) | |
# Rcpp * 0.11.5 2015-03-06 CRAN (R 3.2.0) | |
# RCurl * 1.95-4.6 2015-04-24 CRAN (R 3.2.0) | |
# reshape2 * 1.4.1 2014-12-06 CRAN (R 3.2.0) | |
# rstudioapi * 0.3.1 2015-04-07 CRAN (R 3.2.0) | |
# scales * 0.2.4 2014-04-22 CRAN (R 3.2.0) | |
# stringi * 0.4-1 2014-12-14 CRAN (R 3.2.0) | |
# stringr * 1.0.0 2015-04-30 CRAN (R 3.2.0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment