This function standardises names in a dataset according to the specified output type:
For "electorate" output, it updates electorate names to align with the most recent boundary changes, facilitating consistent analysis across various election years.
For "party" output, it modifies party names to denote successful parties, labeling all unsuccessful parties as "Other". This simplification aids in clear and concise visualisation and analysis. The function is particularly useful for preparing election data for comparative and visual analysis.
Usage
update_names(
data,
nameCol = NULL,
yearCol = "Election",
output = c("party", "electorate")
)
Arguments
- data
A data frame containing election-related information.
- nameCol
The name of the column in
data
that contains names to be updated. If NULL, defaults to "Party" for output "party" and "Electorate" for output "electorate".- yearCol
The name of the column in
data
that contains the election years. This column must be numeric or convertible to numeric.- output
The type of names to be updated; either "party" or "electorate". Defaults to "party".
Examples
if (FALSE) {
data(majority)
updated_majority <- update_names(majority, output = "electorate")
updated_party_votes <- update_names(party_votes, output = "party")
}