Learn R Programming

nzelect (version 0.4.0)

nzge: General Election Results 2002 and onwards

Description

New Zealand general election results by voting place for 2002, 2005, 2008, 2011 and 2014

Usage

nzge

Arguments

Format

A data frame with 728,602 rows and 9 variables.

Details

  • approx_location. Approximate location of voting place

  • vorting_place. Description of exact location of voting place

  • party. Party voted for (party vote) or party of candidate voted for (candidate vote)

  • votes. Number of votes

  • electorate. Electorate in which voters were enrolled. Note that this is not necessarily the physical location of the voting_place, so voting_place and electorate have a many to many relationship

  • voting_type. Party (proportional representation) or Candidate (first past the vote). In New Zealand each voter has to vote for both an individual candidate to represent their electorate, and a party vote for the overall makeup of Parliament.

  • candidate. If voting_type == "Candidate", the name of the candidate; otherwise NA

  • election_year. Year of the election.

  • electorate_number. Number of the electorate.

See Also

voting_places

Examples

Run this code
# NOT RUN {
# the following matches the results published at
# http://www.electionresults.govt.nz/electionresults_2014/e9/html/e9_part1.html
library(tidyr)
library(dplyr)
nzge %>%
    mutate(voting_type = paste0(voting_type, " vote")) %>%
    group_by(party, voting_type, election_year) %>%
    summarise(votes = sum(votes)) %>%
    spread(voting_type, votes) %>%
    ungroup() %>%
    arrange(election_year, desc(`Party vote`))
# }

Run the code above in your browser using DataLab