Political polling data and R code to generate charts for New Zealand election polling data.
Data CSV generation is written in JavaScript for use by Node. The graphing script is written in the R programming language.
- Node.js
- R programming language
- RStudio, a development environment
- Copy the table from Wikipedia into the Scraper tool and generate the corresponding YAML.
- Copy this code into the data.yml file under its respective election section.
- Open your CLI and
cd
into[...]/nzpolls/graphing
. - Run
npm install
to install the necessary dependencies. - Run
node . 2026
(or any other election year) to generate the CSV data file.
- Open RStudio
- Open Tools and click "Install Packages"
- Install the ggplot2 package
- Open
graphing.r
in RStudio and adjust the working directory to[...]/nzpolls/graphing
. - Select all the code in the file and press the "Run" button.
- Export the generated charts as SVG by opening the "Export" option in the plotting window and selecting "Save as image".