knitr::opts_chunk$set(echo = TRUE)
dir <- "~/Dropbox/EL155s"
library(tidyverse)
library(foreach)
library(ballot)
library(purrr)
library(fs)
library(data.table)

Install by

devtools::install_github("kuriwaki/ballot")

Wrapper

A wrapper across all counties in a given election is

subdirs <- dir_ls(path(dir, "input/SC_2017-11-28"), recursive = FALSE)
df <- suppressWarnings(read_format_EL155(subdirs))

To do this county by county, see the following.

Each Function Separately

read_EL155

Read the EL155 file (raw file output for ballot images) and format.

p2016 <- read_EL155(path(dir, "input/SC_2016-06-14/Spartanburg/EL155"), "Spartanburg")
p2016

get_precinct

Add precinct identifier to each row

pkey <- get_precinct(p2016)
head(pkey)
p2016_precinct <- add_precinct(p2016, pkey)
p2016_precinct

parse_EL155

Parse the text with pre-specified fixed width.

p2016_parsed <- parse_EL155(p2016_precinct)
p2016_parsed

identify_voter

Add a unique ID for each voter

with_voter <- identify_voter(p2016_parsed)

add_id

Add voter identifier that will be unique with many counties

df <- add_id(with_voter)


kuriwaki/ballot documentation built on May 1, 2023, 9:55 p.m.