From fd85488378b6aa29bc1cb76bbe11a3343bcbac9b Mon Sep 17 00:00:00 2001 From: dylanshulman <89812072+dylanshulman@users.noreply.github.com> Date: Tue, 29 Oct 2024 12:07:33 -0400 Subject: [PATCH] Update updated_election_scraper_2024.R --- updated_election_scraper_2024.R | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/updated_election_scraper_2024.R b/updated_election_scraper_2024.R index 82365bc..acc27e3 100644 --- a/updated_election_scraper_2024.R +++ b/updated_election_scraper_2024.R @@ -35,7 +35,16 @@ for (row_number in 1:nrow(scraper)) { # Remove totals row table <- table[-nrow(table), ] - + + # Fiddle with Senate so it doesn't name write-in candidates + if (each_row$file_name == "senate.csv") { + table <- table %>% mutate(Total = as.numeric(table$Total)) + write_in_votes <- sum(table$Total[-(1:3)]) + wrow <- data.frame(c1 = "Other Write-Ins", c2 = NA, c3 = NA, c4 = NA, c5 = NA, c6 = NA, c7 = write_in_votes, c8 = NA) + colnames(wrow) <- colnames(table) + table <- table[1:3, ] %>% bind_rows(wrow) + } + # Write the CSV write_csv(table, each_row$file_name) -} \ No newline at end of file +}