-
Notifications
You must be signed in to change notification settings - Fork 21
/
CO.Rmd
264 lines (191 loc) · 8.88 KB
/
CO.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
---
title: "Colorado Early Voting Statistics"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(knitr)
library(kableExtra)
library(scales)
library(DT)
library(highcharter)
state_stats <- read_csv("D:/DropBox/Dropbox/Mail_Ballots_2020/markdown/2020G_Early_Vote.csv")
CO_stats <- read_csv("D:/DropBox/Dropbox/Mail_Ballots_2020/markdown/2020G_Early_Vote_CO.csv")
# Setup
party_shell <- data.frame(Party=character(),
Count=integer(),
Percent=double(),
stringsAsFactors=FALSE)
party_shell[1,1] <- "Democrats"
party_shell[2,1] <- "Republicans"
party_shell[3,1] <- "Minor"
party_shell[4,1] <- "No Party Affiliation"
party_shell[5,1] <- "TOTAL"
race_shell <- data.frame(Race=character(),
Count=integer(),
Percent=double(),
stringsAsFactors=FALSE)
race_shell[1,1] <- "Non-Hispanic White"
race_shell[2,1] <- "Non-Hispanic Black"
race_shell[3,1] <- "Hispanic"
race_shell[4,1] <- "Non-Hispanic Asian American"
race_shell[5,1] <- "Non-Hispanic Native American"
race_shell[6,1] <- "Other/Multiple/Unknown"
race_shell[7,1] <- "TOTAL"
gender_shell <- data.frame(Gender=character(),
Count=integer(),
Percent=double(),
stringsAsFactors=FALSE)
gender_shell[1,1] <- "Female"
gender_shell[2,1] <- "Male"
gender_shell[3,1] <- "Unknown"
gender_shell[4,1] <- "TOTAL"
age_shell <- data.frame(Age=character(),
Count=integer(),
Percent=double(),
stringsAsFactors=FALSE)
age_shell[1,1] <- "18 to 24"
age_shell[2,1] <- "25 to 34"
age_shell[3,1] <- "35 to 44"
age_shell[4,1] <- "45 to 54"
age_shell[5,1] <- "55 to 64"
age_shell[6,1] <- "65 and up"
age_shell[7,1] <- "TOTAL"
party_shell_returned <- data.frame(Party=character(),
Count=integer(),
Frequency=double(),
Count2=integer(),
Rate=integer(),
stringsAsFactors=FALSE)
party_shell_returned[1,1] <- "Democrats"
party_shell_returned[2,1] <- "Republicans"
party_shell_returned[3,1] <- "Minor"
party_shell_returned[4,1] <- "No Party Affiliation"
party_shell_returned[5,1] <- "TOTAL"
# Colorado
CO_voted_party <- party_shell_returned
CO_voted_party[1,2] <- state_stats[6,29] + state_stats[6,77]
CO_voted_party[2,2] <- state_stats[6,30] + state_stats[6,78]
CO_voted_party[3,2] <- state_stats[6,31] + state_stats[6,79]
CO_voted_party[4,2] <- state_stats[6,32] + state_stats[6,80]
CO_voted_party[5,2] <- state_stats[6,6] + state_stats[6,7]
CO_voted_party[1,4] <- state_stats[6,10]
CO_voted_party[2,4] <- state_stats[6,11]
CO_voted_party[3,4] <- state_stats[6,12]
CO_voted_party[4,4] <- state_stats[6,13]
CO_voted_party[5,4] <- state_stats[6,5]
CO_voted_party$Frequency <- 100*CO_voted_party$Count/CO_voted_party[5,2]
CO_voted_party$Rate <- 100*CO_voted_party$Count/CO_voted_party$Count2
colnames(CO_voted_party) <- c("Party", "Total Voted", "Freq. Distribution", "Voter Registration", "Voted Rate")
CO_req_send_party <- party_shell
CO_req_send_party[1,2] <- state_stats[6,10]
CO_req_send_party[2,2] <- state_stats[6,11]
CO_req_send_party[3,2] <- state_stats[6,12]
CO_req_send_party[4,2] <- state_stats[6,13]
CO_req_send_party[5,2] <- state_stats[6,5]
CO_req_send_party$Percent <- 100*CO_req_send_party$Count/CO_req_send_party[5,2]
CO_req_send_party <- party_shell
CO_req_send_party[1,2] <- state_stats[6,10]
CO_req_send_party[2,2] <- state_stats[6,11]
CO_req_send_party[3,2] <- state_stats[6,12]
CO_req_send_party[4,2] <- state_stats[6,13]
CO_req_send_party[5,2] <- state_stats[6,5]
CO_req_send_party$Percent <- 100*CO_req_send_party$Count/CO_req_send_party[5,2]
CO_returned_party <- party_shell
CO_returned_party[1,2] <- state_stats[6,29]
CO_returned_party[2,2] <- state_stats[6,30]
CO_returned_party[3,2] <- state_stats[6,31]
CO_returned_party[4,2] <- state_stats[6,32]
CO_returned_party[5,2] <- state_stats[6,6]
CO_returned_party$Percent <- 100*CO_returned_party$Count/CO_returned_party[5,2]
CO_inperson_party <- party_shell
CO_inperson_party[1,2] <- state_stats[6,77]
CO_inperson_party[2,2] <- state_stats[6,78]
CO_inperson_party[3,2] <- state_stats[6,79]
CO_inperson_party[4,2] <- state_stats[6,80]
CO_inperson_party[5,2] <- state_stats[6,7]
CO_inperson_party$Percent <- 100*CO_inperson_party$Count/CO_inperson_party[5,2]
CO_req_send_gender <- gender_shell
CO_req_send_gender[1,2] <- sum(state_stats[6,21])
CO_req_send_gender[2,2] <- sum(state_stats[6,20])
CO_req_send_gender[3,2] <- sum(state_stats[6,22])
CO_req_send_gender[4,2] <- sum(state_stats[6,5])
CO_req_send_gender$Percent <- 100 * CO_req_send_gender$Count/CO_req_send_gender[4,2]
CO_req_send_age <- age_shell
CO_req_send_age[1,2] <- state_stats[6,23]
CO_req_send_age[2,2] <- state_stats[6,24]
CO_req_send_age[3,2] <- state_stats[6,25]
CO_req_send_age[4,2] <- state_stats[6,26]
CO_req_send_age[5,2] <- state_stats[6,27]
CO_req_send_age[6,2] <- state_stats[6,28]
CO_req_send_age[7,2] <- state_stats[6,5]
CO_req_send_age$Percent <- 100*CO_req_send_age$Count/CO_req_send_age[7,2]
CO_stats <- mutate(CO_stats, Pct.Voted = Voted.Tot/Reg.Voters)
CO_stats_voted <- CO_stats %>%
select(COUNTY, Reg.Voters, Voted.Tot, Pct.Voted)
```
## {.tabset}
Last Report: `r state_stats[6,9]`
Source: `r state_stats[6,2]`
Total Vote: **`r format(as.numeric(state_stats[6,8]), big.mark =",")`**
Total Vote as Percentage of 2016 Total Turnout: **`r paste(round(100*as.integer(state_stats[6,8])/as.integer(state_stats[6,3]), digits = 1),"%", sep = "")`**
Colorado is an all-mail state, with an in-person voting option. To measure participation, I combine voters who have cast mail ballots and in-person votes into a single "Total Voted" category.
### Total Voted
Total Voted: **`r format(as.numeric(state_stats[6,8]), big.mark =",")`**
#### Total Voted by Party Registation
``` {r echo = FALSE}
kable(CO_voted_party, format.args = list(big.mark = ",",
scientific = FALSE), digits = 1) %>%
kable_styling(bootstrap_options = "striped", full_width = F, position = "left")
```
``` {r echo = FALSE}
CO_2020g_map_data <- CO_stats
CO_2020g_map_data$fips <- paste("0",as.character(CO_2020g_map_data$fips), sep="")
CO_2020g_map_data <- mutate(CO_2020g_map_data, percent = round(100*Pct.Voted, digits = 1))
mapfile <- download_map_data("countries/us/us-co-all.js")
mapdata <- get_data_from_map(mapfile)
mapdata$row <- as.integer(rownames(mapdata))
CO_2020g_map_data <- left_join(CO_2020g_map_data, mapdata, by = "fips")
CO_2020g_map_data <- arrange(CO_2020g_map_data, row)
hcmap(map = "countries/us/us-co-all", data = CO_2020g_map_data,
value = "percent", name = "Percent Voted", joinBy = "fips") %>%
hc_title(text ="Turnout Rates") %>%
hc_subtitle(text = "County plots may not be shaded using the same scale")
```
``` {r echo = FALSE}
datatable(CO_stats_voted, colnames = c("County", "Voter Registration", "Total Voted", "Percent Voted"), rownames = F) %>%
formatPercentage('Pct.Voted', 1) %>%
formatRound(c('Voted.Tot', 'Reg.Voters'), 0, mark = ",")
```
### In-Person Early Vote
Ballots Returned: **`r format(as.numeric(state_stats[6,7]), big.mark =",")`**
#### In-Person Vote by Party Registration
``` {r echo = FALSE}
kable(CO_inperson_party, format.args = list(big.mark = ",",
scientific = FALSE), digits = 1) %>%
kable_styling(bootstrap_options = "striped", full_width = F, position = "left")
```
### Mail Ballots Returned and Accepted
Ballots Returned and Accepted: **`r format(as.numeric(state_stats[6,6]), big.mark =",")`**
#### Mail Ballots Returned and Accepted by Party Registration
``` {r echo = FALSE}
kable(CO_returned_party, format.args = list(big.mark = ",",
scientific = FALSE), digits = 1) %>%
kable_styling(bootstrap_options = "striped", full_width = F, position = "left")
```
### Requested Mail Ballots
Ballots Requested: **`r format(as.numeric(state_stats[6,5]), big.mark =",")`**
Colorado is an all-mail ballot state. Ballot requests reported here are counts of the state's registered voters.
#### Mail Ballot Requests by Party Registration
``` {r echo = FALSE}
kable(CO_req_send_party,format.args = list(big.mark = ",",
scientific = FALSE), digits = 1) %>%
kable_styling(bootstrap_options = "striped", full_width = F, position = "left")
```
Colorado registered Democrats have a **`r format(as.numeric(CO_req_send_party[1,2]-CO_req_send_party[2,2]), big.mark =",")`** ballot request lead over registered Republicans.
#### Mail Ballot Requests by Age
``` {r echo = FALSE}
kable(CO_req_send_age, format.args = list(big.mark = ",",
scientific = FALSE), digits = 1) %>%
kable_styling(bootstrap_options = "striped", full_width = F, position = "left")
```