cast_to_wide | R Documentation |
This drops offices where multiple votes are cast for the same contest_code. This is necessary to make a voter uniquely identify a vote for a contest (column). Some offices like congress and state leg are separated out into district-name pairs, with a specific column for a district and the vote in that corresponding district. Absentees are also dropped because they do not have precint information.
cast_to_wide(
df = raw,
contests = c("PTY", "PRS", "USH", "USS", "GOV", "LGV", "SOS", "ATG", "SSI", "HOU",
"SEN", "JPR", "SHF", "COR", "CLR", "AUD", "CTR", "CCL", "CCD", "CCA", "CCC", "SCH",
"WAT", "Q", "LRCA")
)
df |
A standardized long dataset with contest_code and contest_name. Should
have the variables |
contests |
A vector of contest_codes to select and put into the wide. |
A dataset at the individual voter level. For some offices with a district,
these are collapsed to a pair-district pairing. If a voter abstained the
_vote variable is NA
(indeed it was not in the long dataset), but
we try to impute the district by the voter's precinct and ballot style.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.