Overview
scgElectionsNZ
is an R package providing comprehensive data and tools for analyzing New Zealand’s general election results from 1996 to 2023. It offers a unique insight into the dynamics of the electoral process in New Zealand, presented through a variety of datasets and functions.
Datasets Included:
-
summary
: National-level overall results by party. -
turnout
: Electorate and ballot type-specific turnout and informal vote details. -
vote_type
: Validity and method of votes by electorate and ballot. -
party_votes
: Party votes at the electorate level. -
candidate_votes
: Candidate votes at the electorate level. -
majority
: Winning candidates and their margins of victory at the electorate level. -
split_electorate
: Electorate-level split-ticket voting data (2005 - 2023). -
split_total
: National-level split-ticket voting data (2005 - 2023). -
preMMP_results
: National-level results from 1890 to 1993, before MMP. -
historic_turnout
: National-level turnout data from 1879 to 2023.
Installation
To install the development version of scgElectionsNZ
, use:
# Install the development version from GitHub
devtools::install_github("sarahcgall/scgElectionsNZ")
Usage
scgElectionsNZ
includes several helper functions to enhance data analysis:
-
add_data()
: Enhances datasets with regional or electorate type information. -
update_names()
: Standardises electorate names for consistent analysis across years or condense unsuccessful party names into “Other” for easier analysis.
Example usage:
library(scgElectionsNZ)
# Load a dataset
df <- scgUtils::get_data("majority")
# Add additional data
df <- add_data(df, output="regions")
df <- add_data(df, output="type")
# Standardise names
df <- update_names(df, output = "electorate")
df <- update_names(df, output = "party")
Explore detailed examples and dataset descriptions in the package documentation.
Data Sources and Disclaimer
Data Sources
The datasets in the scgElectionsNZ
package are meticulously curated from the official results sourced from the New Zealand Electoral Commission. These datasets offer a comprehensive view of New Zealand’s electoral outcomes and are crucial for in-depth analysis and research in political science, electoral studies, and related fields.
Disclaimer
While the utmost care has been taken to ensure the accuracy and reliability of the data, the New Zealand Electoral Commission was not involved in the development of this package and thus does not bear responsibility for any errors or omissions in the datasets. Users of scgElectionsNZ
should note that the package’s creators have independently compiled, processed, and presented the data. Any discrepancies or inaccuracies found within the datasets do not reflect on the official records maintained by the Electoral Commission.
Future Additions and Updates
Planned future additions include by-election and referendum results and enhanced datasets like results_by_booths
. Upcoming functional updates will focus on visualising election results specific to New Zealand and making boundary adjustments for better comparative analysis.
Feedback and Contributions
Suggestions and contributions are welcome. For any proposed additions, amendments, or feedback, please create an issue.
Related Packages
Check out scgUtils
for additional functions and visualisation tools.