Converts a dataframe with total votes for candidates and total votes by each racial/ethnic group into proportions that can be used for Ecological Inference analysis
stdize_votes_all(
data,
race_cols,
cand_cols,
totals_from = "cand",
totals_col = NULL,
max_dev_race = 0.1,
max_dev_cand = 0.1,
avg_dev_race = 0.025,
avg_dev_cand = 0.025,
new_names = FALSE,
ignore_devs = FALSE,
verbose = TRUE,
diagnostic = FALSE
)
A dataframe containing columns for each race and candidate converted to percentages and a totals column, ready for Ecological Inference
A dataframe of election results, where each row represents a precinct or geographic voting unit
A character vector of colnames corresponding to turnout counts of each race/ethnicity group
A character vector of colnames corresponding to turnout counts of voters for each candidate
A character string, either "cand" or "race" to set whether totals are computed from candidate turnout or race/ethnicity turnout columns. Ignored if totals_col provided.
A character string with the name of the total vote count column in the data. If null, total votes are computed within the function
A numeric object setting the max allowable deviation of any one precincts' sum of race columns from totals
A numeric object setting the max allowable deviation of any one precincts' sum of candidate columns from totals
A numeric object setting the max allowable mean deviation of all precincts' sum of race columns from totals
A numeric object setting the max allowable mean deviation of all precincts' sum of candidate columns from totals
A boolean indicating whether to return cand and race columns with the same names. If FALSE, names returned with "_prop" added on.
A boolean. When true, columns are standardized ignoring all deviations from totals
A boolean. When true, function returns progress messages.
A boolean. When true, an extra column of booleans is returned indicating whether each row had a deviation from totals
Ari Decter-Frain