[R] Year and Month extraction from Date object.

rkevinburton at charter.net rkevinburton at charter.net
Tue Oct 27 22:49:00 CET 2009


Hello,

I have seen much discussion on Date. But I can't seem to do this simple operation. I can convert a string to a date:

d <- as.Date(DATE, format="%m/%d/%Y")

But what I want to do is extract the year and month so I can construct an element in a ts object. Ideally I would like to see d$year but that doesn't seem to be available. Once I have a Date object how can I get an integer year?

Thank you.

Kevin




More information about the R-help mailing list