generated from jtr13/bookdown-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
95 lines (80 loc) · 3.77 KB
/
index.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
---
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
---
# Project Biden
<p>
Project Biden is looking at the approval ratings since the beginning of the first term in 2021. The polls used are sourced from *538.com*.
<p/>
## Biden approval chart
<p>
The chart uses polling from <code>538.com</code> calculated to a 7-day rolling average and fit the trend lines with **Loess** regression curves with a span of <code>0.1</code>.
<p/>
```{r biden_approval,echo = FALSE, results = 'hide', warning = FALSE,message=FALSE,fig.dpi=1080, fig.height=5,fig.width=9,fig.align='center',fig.cap="President Biden Approval chart"}
library(ggplot2)
library(dplyr)
library(zoo)
library(lubridate)
library(tidyverse)
library(readxl)
buden_ <- read_excel("~/buden_.xltx", sheet = "clean")
buden_$end_date<-mdy(buden_$end_date)
biden<-buden_%>%
mutate(app_7d = rollmeanr(share, k=7, fill=NA))
ggplot(biden, mapping = aes(x=end_date, y=app_7d,color=approval))+
geom_point(alpha=1/10,size=5) +
geom_smooth(method = 'loess', formula = 'y~x',span=0.1, se=FALSE, lwd=2)+
scale_colour_manual(values = c('tomato','grey','black'))+
labs(title = 'Approve the job President Biden is doing?',caption = "sources:538.com\njamesstats.github.io/blog", x='',
y='%Percentage%', colour=' ')+
theme_bw()+
theme(legend.position = 'bottom') +
theme(plot.title = element_text(face = "bold"),
plot.caption = element_text(face = 'italic'),axis.text = element_text(face = 'bold'))
```
## Methodology used by pollsters
<p>
Majority of the polls are conducted through the live phone and the others are a mix of live phone,online panel and text based.
<p/>
```{r polls_method,echo = FALSE, results = 'hide', warning = FALSE,message=FALSE,fig.dpi=1080, fig.height=5,fig.width=8,fig.align='center',fig.cap="The Different ways pollsters conduct their polls"}
library(ggplot2)
library(lubridate)
library(tidyverse)
library(readxl)
buden_ <- read_excel("~/buden_.xltx", sheet = "clean")
buden_$end_date<-mdy(buden_$end_date)
ggplot(biden, mapping = aes(x=end_date, y=app_7d,color=approval))+
geom_point(alpha=1/10,size=5) +
geom_smooth(method = 'loess', formula = 'y~x',span=1, se=FALSE, lwd=2)+
scale_colour_manual(values = c('tomato','grey','black'))+
labs(title = 'How the polls are conducted',caption = "sources:538.com\njamesstats.github.io/blog", x='',
y='%Percentage%', colour=' ')+
theme_bw()+
theme(legend.position = 'bottom') +
theme(plot.title = element_text(face = "bold"),
plot.caption = element_text(face = 'italic'),axis.text = element_text(face = 'bold')) +
facet_wrap(~methodology)
```
## A-list pollsters
<p>
A comparison of the A-list/rated pollsters by **538.com** who have conducted nation polls on President Biden on how they stack against each other. Marist Polls seems to be more bullish on Biden than the others.
<p/>
```{r A_polls,echo = FALSE, results = 'hide', warning = FALSE,message=FALSE,fig.dpi=1080, fig.height=5,fig.width=8,fig.align='center',fig.cap="Individual results from the pollsters"}
library(ggplot2)
library(lubridate)
library(tidyverse)
library(readxl)
buden_ <- read_excel("~/buden_.xltx", sheet = "clean")
buden_$end_date<-mdy(buden_$end_date)
ggplot(biden, mapping = aes(x=end_date, y=app_7d,color=approval))+
geom_point(alpha=1/10,size=5) +
geom_smooth(method = 'loess', formula = 'y~x',span=1, se=FALSE, lwd=2)+
scale_colour_manual(values = c('tomato','grey','black'))+
labs(title = 'Pollsters and their polls',x='',caption = "sources:538.com\njamesstats.github.io/blog",
y='%Percentage%', colour=' ')+
theme_bw()+
theme(legend.position = 'bottom') +
theme(plot.title = element_text(face = "bold"),
plot.caption = element_text(face = 'italic'),axis.text = element_text(face = 'bold')) +
facet_wrap(~pollster)
```