# Create charts of processed monthly mean NZU prices
# download monthly price data from Github
# make a short 'list' for the url of the data at Github
urldata <- c("https://raw.githubusercontent.com/theecanmole/nzu/master/nzu-month-price.csv")
# define the destination file name and location
monthprice <-c("nzu-month-price.csv")
download.file(urldata, monthprice)
# or read in the price data from the .csv file in the destination folder
monthprice <- read.csv("nzu-month-price.csv", skip=0, header=TRUE, sep=",", colClasses = c("Date","numeric"),na.strings="NA", dec=".", strip.white=TRUE)
# create time series of price data
mpts <- ts(data = monthprice[["price"]], start =c(2010, 5), deltat = 1/12)
# Create svg format graph
svg(filename="NZUprice-720by540.svg", width = 8, height = 6, pointsize = 16, onefile = FALSE, family = "sans", bg = "white", antialias = c("default", "none", "gray", "subpixel"))
par(mar=c(2.7,2.7,1,1)+0.1)
plot(mpts,tck=0.01,axes=TRUE,ann=TRUE,las=1,col="red",lwd=2,type='l',lty=1)
grid(col="darkgray",lwd=1)
axis(side=4, tck=0.01, las=0,tick=TRUE,labels = FALSE)
mtext(side=1,cex=0.75,line=-1.1,"Data: 'NZU monthly prices' https://github.com/theecanmole/nzu")
mtext(side=3,cex=1.5, line=-2.2,expression(paste("New Zealand Unit Prices 2010 - 2024")) )
mtext(side=2,cex=1, line=-1.3,"$NZ Dollars/tonne")
mtext(side=4,cex=0.75, line=0.05,R.version.string)
dev.off()