-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathstandardize.qmd
188 lines (176 loc) · 9.19 KB
/
standardize.qmd
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
```{r}
library(tidyverse)
```
```{r}
ny_statewide <- read_csv("2020/20201103__ny__general__precinct.csv",
col_types = cols(district = col_double(), election_day=col_double(), affidavit = col_double(), early_voting = col_double(), military = col_double(), federal = col_double(), provisional = col_double()))
```
```{r}
ny_parties <- ny_statewide %>% distinct(party)
```
```{r}
ny_statewide_parties <- ny_statewide %>% mutate(party = case_when(
party == 'LaRouche' ~ 'LAR',
party == 'Larouche' ~ 'LAR',
party == 'LRE' ~ 'LAR',
party == 'LI' ~ 'LAR',
party == 'LIB' ~ 'LBT',
party == 'Rep' ~ 'REP',
party == 'WORK' ~ 'WOR',
party == 'WFP' ~ 'WOR',
party == 'Dem' ~ 'DEM',
party == 'Democratic' ~ 'DEM',
party == 'Republican' ~ 'REP',
party == 'REP.' ~ 'REP',
party == 'Conservative' ~ 'CON',
party == 'CON.' ~ 'CON',
party == 'IND.' ~ 'IND',
party == 'Working Families' ~ 'WOR',
party == 'Moderate' ~ 'MOD',
party == 'GOP' ~ 'REP',
party == 'Integrity' ~ 'INT',
party == 'LBN' ~ 'LBT',
party == 'Justice & Peace' ~ 'J&P',
party == 'Save Our City' ~ 'SOC',
party == 'Proven Leader' ~ 'PVL',
party == 'Rise and Unite' ~ 'RAU',
party == 'New Moderate' ~ 'NMO',
party == 'COVID19 Stories' ~ 'CVD',
party == 'Liberal' ~ 'LIB',
TRUE ~ party
))
```
```{r}
ny_cands <- ny_statewide_parties %>% distinct(office, district, candidate, party) %>% mutate(candidate = str_to_title(candidate)) %>% filter(!candidate %in% c('Blanks','Under Votes', 'Bvs', 'Over and Under Votes', 'Over Votes', 'Special Votes', 'Voids', 'Void', 'Write-in', 'Blank', 'Void', 'Absentee / Military', 'Affidavit', 'Blank/Void', 'Write-In', 'Overvotes', 'Undervotes', 'Unqualified Write-Ins', 'Write-Ins', 'Scattered', 'Public Counter', 'Manually Counted Emergency', 'Federal', 'Scattering', 'Over Vote', 'Under Vote', 'Scatter', 'Undervote', 'Overvote', 'Undervotess', 'Unqualified Write-In', 'Overvotess')) %>% filter(!is.na(candidate))
```
```{r}
ny_cands %>% distinct(party)
```
```{r}
ny_cands <- ny_statewide_parties %>% distinct(office, district, candidate) %>% mutate(candidate = str_squish(str_to_title(candidate))) %>% filter(!candidate %in% c('Blanks','Under Votes', 'Bvs', 'Over and Under Votes', 'Over Votes', 'Special Votes', 'Voids', 'Void', 'Write-in', 'Blank', 'Void', 'Absentee / Military', 'Affidavit', 'Blank/Void', 'Write-In', 'Overvotes', 'Undervotes', 'Unqualified Write-Ins', 'Write-Ins', 'Scattered', 'Public Counter', 'Manually Counted Emergency', 'Federal', 'Scattering', 'Over Vote', 'Under Vote', 'Scatter', 'Undervote', 'Overvote', 'Undervotess', 'Unqualified Write-In', 'Overvotess', 'Ballots', 'Ballots Cast', 'Blanks/Voids')) %>% filter(!is.na(candidate))
```
```{r}
ny_master <- ny_statewide_parties %>%
mutate(candidate = str_squish(str_to_title(candidate))) %>%
mutate(candidate = case_when(
candidate == 'Jorgensen/Cohen' ~ 'Jo Jorgensen',
candidate == 'Jo Jorgensen / Jeremy Cohen' ~ 'Jo Jorgensen',
candidate == 'Jo Jorgensen And Jeremy Cohen' ~ 'Jo Jorgensen',
candidate == 'Jo Jorgensen Jeremy Cohen' ~ 'Jo Jorgensen',
candidate == 'Jo Jorgensen/Jeremy Cohen' ~ 'Jo Jorgensen',
candidate == 'Brock Pierce / Karla Ballard' ~ 'Brock Pierce',
candidate == 'Brock Pierce And Karla Ballard' ~ 'Brock Pierce',
candidate == 'Brock Pierce Karla Ballard' ~ 'Brock Pierce',
candidate == 'Brock Pierce/Karla Ballard' ~ 'Brock Pierce',
candidate == 'Colton Menning' ~ 'Colton Mennig',
candidate == 'Christopher Friend' ~ 'Christopher S. Friend',
candidate == 'Daniel Brown' ~ 'Daniel J. Brown',
candidate == 'Dan Butterman' ~ 'Dan Buttermann',
candidate == 'Daniel G Stec' ~ 'Daniel G. Stec',
candidate == 'David Catalfamo' ~ 'David M. Catalfamo',
candidate == 'David M Catalfamo' ~ 'David M. Catalfamo',
candidate == 'Dianne Sare' ~ 'Diane Sare',
candidate == 'Edward A. Rath Iii' ~ 'Edward A. Rath III',
candidate == 'Elise M Stefanik' ~ 'Elise M. Stefanik',
candidate == 'Elise Stefanik' ~ 'Elise M. Stefanik',
candidate == 'George A.d. Santos' ~ 'George Santos',
candidate == 'George Borrello' ~ 'George M. Borrello',
candidate == 'Jacob C Ashby' ~ 'Jacob C. Ashby',
candidate == 'Jean A Lapper' ~ 'Jean A. Lapper',
candidate == 'Jennifer A.o. Keys' ~ 'Jennifer Keys',
candidate == 'Jennifer O. Keys' ~ 'Jennifer Keys',
candidate == 'John T. Mcdonald' ~ 'John T. McDonald III',
candidate == 'John T. Mcdonald' ~ 'John T. McDonald III',
candidate == 'John T. Mcdonald, Iii' ~ 'John T. McDonald III',
candidate == 'Joseph Giglio' ~ 'Joseph M. Giglio',
candidate == 'Julie Shiroshi' ~ 'Julie Shiroishi',
candidate == 'Kathleen M. Valetta' ~ 'Kathleen M. Valletta',
candidate == 'Kathy C Hochul' ~ 'Kathy C. Hochul',
candidate == 'Kathy Hochul' ~ 'Kathy C. Hochul',
candidate == 'Kenneth Blankenbush' ~ 'Kenneth D. Blankenbush',
candidate == 'Letitia A James' ~ 'Letitia A. James',
candidate == 'Letitia James' ~ 'Letitia A. James',
candidate == 'Marcus Molinaro' ~ 'Marc Molinaro',
candidate == 'Mark Walczyk' ~ 'Mark C. Walczyk',
candidate == 'Matthew J Simpson' ~ 'Matthew J. Simpson',
candidate == 'Max Della Pia' ~ 'Max H. Della Pia',
candidate == 'Max H. Della' ~ 'Max H. Della Pia',
candidate == 'Nick Langworth' ~ 'Nick Langworthy',
candidate == 'Pam Helming' ~ 'Pamela A. Helming',
candidate == 'Phillip A. Palmesano' ~ 'Philip A. Palmesano',
candidate == 'Richard M. Amedure, Jr' ~ 'Richard M. Amedure, Jr.',
candidate == 'Scott H Bendett' ~ 'Scott H. Bendett',
candidate == 'Stephen H. Chilton Iii' ~ 'Stephen H. Chilton III',
candidate == 'Stephen H. Chilton, Iii' ~ 'Stephen H. Chilton III',
candidate == 'Stephen Hawley' ~ 'Stephen M. Hawley',
candidate == 'Steven J. Dellavecchi' ~ 'Steven J. Dellavecchia',
candidate == 'Steven L. Sams Ii' ~ 'Steven L. Sams II',
candidate == 'Steven L. Sams, Ii' ~ 'Steven L. Sams II',
candidate == 'Thomas Dinapoli' ~ 'Thomas P. DiNapoli',
candidate == 'Thomas P Dinapoli' ~ 'Thomas P. DiNapoli',
candidate == 'Thomas P. Dinapoli' ~ 'Thomas P. DiNapoli',
candidate == "Thomas O'mara" ~ "Thomas F. O'Mara",
candidate == "Thomas F. O'mara" ~ "Thomas F. O'Mara",
candidate == 'William C. Conrad Iii' ~ 'William C. Conrad III',
candidate == 'William C. Conrad, Iii' ~ 'William C. Conrad III',
candidate == 'Andrew Gauzza Iv' ~ 'Andrew Gauzza IV',
candidate == "Andrew Gauzza, Iv" ~ 'Andrew Gauzza IV',
candidate == 'Andrew M Kolstee' ~ 'Andrew M. Kolstee',
candidate == 'Anthony Brindisi' ~ 'Anthony J. Brindisi',
candidate == 'Barbara Kidney' ~ 'Barbara A. Kidney',
candidate == 'Blankenship Don' ~ 'Don Blankenship',
candidate == 'Write-Ins Don Blankenship' ~ 'Don Blankenship',
candidate == 'Brian Carroll Write-Ins' ~ 'Brian Carroll',
candidate == 'Carroll Brian' ~ 'Brian Carroll',
candidate == 'Brittany L Vogel' ~ 'Brittany L. Vogel',
candidate == 'Chad Mcevoy' ~ 'Chad J. McEvoy',
candidate == 'Chad J. Mcevoy' ~ 'Chad J. McEvoy',
candidate == 'Charles A Senrick' ~ 'Charles A. Senrick',
candidate == 'Chele Farley' ~ 'Chele C. Farley',
candidate == 'Chris Jacobs Rep' ~ 'Chris Jacobs',
candidate == 'Chris Jacos' ~ 'Chris Jacobs',
candidate == 'Claudia K Braymer' ~ 'Claudia K. Braymer',
candidate == 'Comegys' ~ 'Scott Comegys',
candidate == 'Daphne V Jordan' ~ 'Daphne V. Jordan',
candidate == 'Ballots' ~ 'Ballots Cast',
candidate == 'De La Fuente Roqu' ~ 'Roque "Rocky" De La Fuente',
candidate == 'Roque De La Fuente' ~ 'Roque "Rocky" De La Fuente',
candidate == 'Duane Whitmer' ~ 'Duane J. Whitmer',
candidate == 'Edward Rath Iii' ~ 'Edward A. Rath III',
candidate == 'Edward A. Rath Iii' ~ 'Edward A. Rath III',
candidate == 'Elijah Reichlin Melnick' ~ 'Elijah Reichlin-Melnick',
candidate == 'Elijah Reichlin- Melnick' ~ 'Elijah Reichlin-Melnick',
candidate == 'Evelyn M Wood' ~ 'Evelyn M. Wood',
candidate == 'Frederick J. Akshar Ii' ~ 'Frederick J. Akshar II',
candidate == 'Frederick J. Akshar, Ii' ~ 'Frederick J. Akshar II',
candidate == 'George M. Borrello' ~ 'George M. Borello',
candidate == 'Gloria Lariva' ~ 'Gloria La Riva',
candidate == 'Helming' ~ 'Pamela A. Helming',
candidate == 'Jacqualine Berger' ~ 'Jacqualine G. Berger',
candidate == 'Jake Cormell' ~ 'Jake Cornell',
candidate == 'James Tedisco' ~ 'James N. Tedisco',
candidate == 'John Katko' ~ 'John M. Katko',
candidate == 'Katko' ~ 'John M. Katko',
candidate == 'John Lemondes, Jr.' ~ 'John Lemondes Jr.',
candidate == 'John T. Mcdonald Iii' ~ 'John T. McDonald III',
candidate == 'John Zielinski' ~ 'John S. Zielinski',
candidate == 'Kanye West Write-Ins' ~ 'Kanye West',
candidate == 'Kayne West' ~ 'Kanye West',
candidate == 'Keith Price Jr.' ~ 'Keith D. Price Jr.',
candidate == 'Kevin Collery Write-Ins' ~ 'Kevin Collery',
candidate == 'Kimberly A Davis' ~ 'Kimberly A. Davis',
candidate == 'Manktelow' ~ 'Brian D. Manktelow',
candidate == 'Mark Glogowski' ~ 'Mark E. Glogowski',
candidate == 'Michael Gentile' ~ 'Michael C. Gentile',
TRUE ~ candidate
))
```
```{r}
ny_master %>%
group_by(candidate) %>%
summarize(total = sum(votes)) %>%
arrange(candidate)
```
```{r}
write_csv(ny_master, "2020/20201103__ny__general__precinct.csv", na="")
```