reshape_precinct_data: Reshape County Precinct Data for Candidates to OpenElex...

Description Usage Arguments Value Examples

View source: R/precinct_processing_functions.R

Description

This function is designed to take a wide dataset with one row per precinct and candidate vote columns and reshape once the initial pre-processing is done. The file to import should have have a precinct column, followed by columns with vote results formatted as "candidate - party". The resulting dataframe will be long/tidy data with these columns: precinct, office, district, party, votes.

Usage

1
reshape_precinct_data(df, office, district)

Arguments

df

formatted dataframe of county precinct-level results

office

which office the results refer to (e.g. "presidential", "U.S. House", "State Senate", etc.)

district

number for what district is associated with the office (e.g. "45" for the 45th congressional district. note presidential should be left blank as "")

Value

a reshaped dataframe in openelex long/tidy format

Examples

1
2
3
4
## Not run: 
reshape_precinct_data(mydataframe)

## End(Not run)

amkessler/precinctsopenelex documentation built on Feb. 5, 2021, 9:27 p.m.