New Zealand · R

What is orange and been in the news

Carrot prices http://www.stuff.co.nz/business/90367412/a-kilogram-of-carrots-costs-over-a-dollar-more-than-last-year Looking at both the raw (so to speak) and seasonally adjusted figures, it looks to me like carrots, as the most extreme difference, got a discussion in the press release, but there is more of a steady upward creep in prices generally. The released figures go to the Fruit and Vegetable level,… Continue reading What is orange and been in the news

New Zealand · R

New Zealand Names

This is just showing how to process the New Zealand baby names spreadsheet provided by the New Zealand Governemnt, and also make streamgraphs, available from github with devtools::install_github(“hrbrmstr/streamgraph”) download.file(“https://smartstart.services.govt.nz/assets/files/Top-baby-names-1954-2016.xlsx&#8221;, destfile=”babynames.xlsx”, mode=”wb”, method=”libcurl”) library(readxl) library(dplyr) library(streamgraph) female <- read_excel(“~/Desktop/babynames.xlsx”, sheet = “Girls’ Names”, col_names = FALSE, skip = 7) female <- female[1:100,] male <- read_excel(“~/Desktop/babynames.xlsx”, sheet… Continue reading New Zealand Names

New Zealand · R

The right map projection

You know how people say it is important to use the right map projection? What they said, illustrated. library(maps) library(mapproj) png(filename=”default.png”, width = 320, height = 320) map(“nz”) dev.off() projec <- “mercator” png(filename=paste(projec ,”png”, sep=”.”), width = 320, height = 320) map(“nz”, proj=projec) dev.off() projec <- “sinusoidal” png(filename=paste(projec ,”png”, sep=”.”), width = 320, height =… Continue reading The right map projection

New Zealand · R

The sun causes earthquakes

I sat down to write a satirical blog post, but the results I got disturbed me. I used the Geonet quake catalogue to download the past 5 years of New Zealand earthquake data from http://info.geonet.org.nz/display/appdata/Earthquake+Catalogue library(dplyr) library(lubridate) library(ggplot2) if(file.exists(“eqnz.csv”)){ eq <- read.csv(“eqnz.csv”, stringsAsFactors=FALSE) } else{ e1 <- read.csv(“http://quakesearch.geonet.org.nz/csv?bbox=163.03711,-49.32512,182.41699,-32.47270&startdate=2015-09-01&enddate=2016-09-01&#8221;, stringsAsFactors=FALSE) e2 <- read.csv(“http://quakesearch.geonet.org.nz/csv?bbox=163.03711,-49.32512,182.41699,-32.47270&startdate=2014-08-01&enddate=2015-09-01&#8221;, stringsAsFactors=FALSE) e3 <- read.csv(“http://quakesearch.geonet.org.nz/csv?bbox=163.03711,-49.32512,182.41699,-32.47270&startdate=2013-09-01&enddate=2014-08-01&#8221;,… Continue reading The sun causes earthquakes

New Zealand · R

New Zealand Election Survey 2014 processing code

This is the code that lies under a (less technical) article on the NZES I wrote published on Public Address, in more or less the order it is used in the article Data setup and organisation #for all subsequent code chunks, this chunk is assumed to be run and the libraries loaded. if(!require(haven)){ install.packages(“haven”) require(haven)… Continue reading New Zealand Election Survey 2014 processing code