June 2016
Beginner to intermediate
1783 pages
71h 22m
English
In this recipe, we will learn how to choose the formatting of time axis labels, instead of just using the defaults.
We will only use the basic R functions for this recipe. Make sure that you are at the R prompt and load the openair.csv dataset:
air<-read.csv("openair.csv")Let's redraw our original example involving plotting air pollution data from the last recipe, but with labels for each month and year pairing:
plot(air$nox~as.Date(air$date,"%d/%m/%Y %H:%M"),type="l", xaxt="n", xlab="Time", ylab="Concentration (ppb)", main="Time trend of Oxides of Nitrogen") xlabels<-strptime(air$date, format = "%d/%m/%Y %H:%M") axis.Date(1, at=xlabels[xlabels$mday==1], format="%b-%Y") ...
Read now
Unlock full access