Learn R Programming

eiCompare (version 3.0.4)

dedupe_precincts: Remove or identify duplicated precincts

Description

Removes any rows in the dataset that are fully duplicated. If necessary, adds ' duplicates' column indicating where precincts appear duplicated, for manual inspection by the user

Usage

dedupe_precincts(data, id_cols, verbose = TRUE)

Value

A new dataframe without duplicated rows, and (if any) a boolean column identifying duplicated precincts for further investigation.

Arguments

data

A data.frame() object containing precinct-level turnout data by race and candidate

id_cols

The name or index of the column in the data containing unique precinct identifiers. Can pass multiple column names or indices in a vector if precincts are identified over multiple columns (eg. c("precinctid", "countyid")).

verbose

A boolean. If true, messages are returned describing actions taken by the function.

Author

Ari Decter-Frain <agd75@cornell.edu>