# manually download "Series GDP(E) Nominal Actual Total Annual-Mar" from https://infoshare.stats.govt.nz/SearchPage.aspx and save it to the working directory
# read in data
sneam <- read.csv("SNE439802_20250620_045827_11.csv", skip = 2)
# delete non-data rows from row 55 down
sneam <- sneam[1:54,]
# assign names
names(sneam) <- c("Year","GDP")
# change format to numeric
sneam[["GDP"]] <- as.numeric(sneam[["GDP"]])
# change GDP from millions to billions
sneam[["GDP"]] <- sneam[["GDP"]]/10^3
# create new dataframe
# create dataframe of date and GDP value
sneamdf <- data.frame(Date=seq(as.Date("1972/03/31"), by = "year", length.out = 54), GDP= sneam[["GDP"]])
# create svg format chart
svg(filename="StatsSNE-GDPE-1972-2025-gdp-720by540.svg", width = 8, height = 6, pointsize = 14, onefile = FALSE, family = "sans", bg = "white", antialias = c("default", "none", "gray", "subpixel"))
plot(sneamdf,ylim=c(0,430),xlim=c(820,19813),tck=0.01,axes=T,ann=T, las=1,col="red",lwd=1,type='l',lty=1,xlab ="",ylab="")
grid(col="darkgray",lwd=1)
lines(sneamdf,col="red")
points(sneamdf,pch=19,cex=0.75,col="red")
axis(side=4, tck=0.01, las=0,tick=TRUE,labels = FALSE)
mtext(side=1,cex=0.8,line=-1.1,"Data: Stats NZ Series GDP(E) Nominal Actual Total Annual-Mar https://infoshare.stats.govt.nz")
mtext(side=3,cex=1.3, line=-2.2,expression(paste("New Zealand Gross Domestic Product 1972 to 2025")) )
mtext(side=2,cex=1, line=-1.3,"Nominal billion $NZD")
mtext(side=4,cex=0.75, line=0.05,R.version.string)
dev.off()