R⁶ — Disproving Approval
[This article was first published on R – rud.is, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
I couldn’t let this stand unchallenged:
The new Rasmussen Poll, one of the most accurate in the 2016 Election, just out with a Trump 50% Approval Rating.That's higher than O's #'s!
— Donald J. Trump (@realDonaldTrump) June 18, 2017
Ramussen makes their Presidential polling data available for both ? & O. Why not compare their ratings from day 1 in office (skipping days that Ramussen doesn’t poll)?
library(hrbrthemes) library(rvest) library(tidyverse) list( Obama="http://m.rasmussenreports.com/public_content/politics/obama_administration/obama_approval_index_history", Trump="http://m.rasmussenreports.com/public_content/politics/trump_administration/trump_approval_index_history" ) %>% map_df(~{ read_html(.x) %>% html_table() %>% .[[1]] %>% tbl_df() %>% select(date=Date, approve=`Total Approve`, disapprove=`Total Disapprove`) }, .id="who") -> ratings mutate_at(ratings, c("approve", "disapprove"), function(x) as.numeric(gsub("%", "", x, fixed=TRUE))/100) %>% mutate(date = lubridate::dmy(date)) %>% filter(!is.na(approve)) %>% group_by(who) %>% arrange(date) %>% mutate(dnum = 1:n()) %>% ungroup() %>% ggplot(aes(dnum, approve, color=who)) + geom_hline(yintercept = 0.5, size=0.5) + geom_point(size=0.25) + scale_y_percent(limits=c(0,1)) + scale_color_manual(name=NULL, values=c("Obama"="#313695", "Trump"="#a50026")) + labs(x="Day in office", y="Approval Rating", title="Presidential approval ratings from day 1 in office", subtitle="For fairness, data was taken solely from Trump's favorite polling site (Ramussen)", caption="Data Source: <rasmussenreports.com>\nCode: <https://gist.github.com/hrbrmstr/a7310e1b64d0797401d01d0c6195bd8b>") + theme_ipsum_rc(grid="XY", base_size = 16) + theme(legend.direction = "horizontal") + theme(legend.position=c(0.8, 1.05))
I’ll make a new post occasionally throughout ?’s term.
To leave a comment for the author, please follow the link and comment on their blog: R – rud.is.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.