Skip to content

Commit

Permalink
Update updated_election_scraper_2024.R
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanshulman authored Oct 29, 2024
1 parent 9b6c820 commit fd85488
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions updated_election_scraper_2024.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit fd85488

Please sign in to comment.