Introduction
The nzelect
R package which I first introduced in a blog post in April is now available on CRAN. The version number is 0.2.0.
The difference from version 0.1.0 is sizeable - all the 2013 census data has been removed and is now in a companion package, nzcensus
. This is for ease of development and maintenance, and to allow organisations that aren’t interested in the election results still to use the census data. It also keeps the package size within CRAN guidelines. I’ll write about nzcensus
in a separate post; its coverage has somewhat expanded from when I last blogged about combining census and election data. nzcensus
is only available from GitHub due to its size.
The changes to nzelect
and the creation of nzcensus
are not backwards-compatible; the code in posts I wrote in April will no longer run out of the box. However, the changes needed are small and in the comments under those posts I’ve provided links to working versions.
I was very pleased when last week the New Zealand Herald used my nzelect
package and example analysis in my blog as the basis for a more comprehensive piece of analysis and interactive web application on “How New Zealand Votes”.
The New Zealand Electoral Commission had no involvement in preparing this package and bear no responsibility for any errors. In the event of any uncertainty about election results, refer to the definitive source materials on their website.
Usage
The functionality of the voting results part of the nzelect
package hasn’t changed since the GitHub version in April. All the results are verified against the official election results. Results are available by voting place and are easy to aggregate up by electorate of enrolment and by meshblock, area unit, territorial authority and regional council by voting location. The package has a vignette with some basic analysis ideas.
Here’s one idea that’s not in the vignette - mapping the precise casting location of party votes in a city:
Here’s the code for producing that map of Christchurch. Thanks to David Kahle and Hadley Wickham for the ggmap
package which makes it easy (amongst other things) to provide backgrounds for maps. These particular map tiles are by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.
Next steps
Next steps for nzelect
include:
- add individual level data from the New Zealand Election Study
- add results from 2011 and earlier elections
- more example analysis of combinations of
nzelect
andnzcensus
.
Please file bugs or enhancement requests as issues on GitHub.