Q:

x axis with time series, comparing years

I want to plot a graph so I can compare the temperature trend over time, specially looking at how different is between years.
It is a long dataset, so I will paste a sample of it:
       DATE     N      TEMP    min  max YEAR
1   2012-09-01 24   16.116667 15.9 16.4 2012
2   2012-09-02 24   16.433333 16.3 16.8 2012
3   2012-09-03 24   16.300000 16.2 16.5 2012
4   2012-09-04 24   16.508333 16.3 16.8 2012
5   2012-09-05 24   16.275000 16.1 16.5 2012
6   2012-09-06 24   16.166667 15.9 16.7 2012
7   2012-09-07 24   16.825000 16.8 16.9 2012
8   2012-09-08 24   16.729167 16.6 16.8 2012
9   2012-09-09 24   16.566667 16.4 16.8 2012
10  2012-09-10 24   16.925000 16.7 17.0 2012
11  2012-09-11 24   16.579167 16.3 16.8 2012
12  2012-09-12 24   16.258333 16.2 16.5 2012

The dataset carries on till 2015.
Its str(df):
       'data.frame':    955 obs. of  6 variables:
 $ DATE       : Date, format: "2012-09-01" "2012-09-02" "2012-09-03" ...
 $ N          : num  24 24 24 24 24 24 24 24 24 24 ...
 $ TEMPERATURE: num  16.1 16.4 16.3 16.5 16.3 ...
 $ min        : num  15.9 16.3 16.2 16.3 16.1 15.9 16.8 16.6 16.4 16.7 ...
 $ max        : num  16.4 16.8 16.5 16.8 16.5 16.7 16.9 16.8 16.8 17 ...
 $ YEAR       : Factor w/ 4 levels "2012","2013",..: 1 1 1 1 1 1 1 1 1 1 ...

The plot:
ggplot(DailyTemp, aes(DATE, TEMPERATURE, group=YEAR, colour=YEAR)) + geom_line( ) + facet_grid(YEAR~.)

I would like to have x axis with only months Jan to Dec and not a timeseries with all the years. So temp for 2012, 2013, 2014 are in the same x axis position but one over the other.

A:

You just need to set the year to be the same for all dates in the DATE column before plotting:
year(DailyTemp$DATE) <- 2012

(It shouldn't matter what year you set them all to, since the x-axis will just show Jan through Dec).

