I have data for a year covering two calendar years. I want to build boxes for these subsets of monthly data.
The charts will always be ordered alphabetically (if I use the names of the months) or numerically (if I use the numbers of the month). My goal doesn't suit me.
In the example below, I want the months on the x-axis to start in June (2013) and end in May (2014).
date <- seq.Date(as.Date("2013-06-01"), as.Date("2014-05-31"), "days")
set.seed(100)
x <- as.integer(abs(rnorm(365))*1000)
df <- data.frame(date, x)
boxplot(df$x ~ months(df$date), outline = FALSE)
Perhaps I could generate a vector of months in the order I need (for example, months <- months(seq.Date(as.Date("2013-06-01"), as.Date("2014-05-31"), "month")))
Is there a more elegant way to do this? What am I missing?
source
share