I have problems sorting data by month and year. I'm using as.yearmon()
as shown here. However, some months are not recognized by as.yearmon
function (march, mai, october, december). I found out that using German abbreviations instead of English abbreviations works fine, for example Dez
instead od Dec
. Also tried caps and no caps. It seems to by a default setting or I miss a command in the as.yearmon function. Ideas?? Here some sample data:
dat <- c("2009-Sep","2009-Feb","2009-Jan","2009-Oct")
require(zoo)
d2 <- as.yearmon(dat, "%Y-%b")
sort(d2)
In this case I lose the last entry 2009-Oct and I don't know why. My output is only:
"Jan 2009" "Feb 2009" "Sep 2009"
However, using this (note Okt
instead of Oct
, german style):
dat <- c("2009-Sep","2009-Feb","2009-Jan","2009-Okt")
I get the wright output. Do you have ideas how to solve this problem? Thanks