Hello!

I'd like to take Dates and extract from them months and years - but so
that it sorts correctly. For example:

x1<-seq(as.Date("2009-01-01"), length = 14, by = "month")
(x1)
order(x1)  # produces correct order based on full dates

# Of course, I could do "format" - but this way I am losing the "Date"
quality of the data:

x2<-format(x1,"%Y.%m")
(x2)
order(x2)

Not sure it's possible at all: But is there some other way to extract
just months and years from Dates (while ingoring days) - but so that
it's still somehow a Date object?

Thank you very much!

-- 
Dimitri Liakhovitski
Ninah Consulting
www.ninah.com

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to