?weekdays contains

Note:

     Other components such as the day of the month or the year are very
     easy to compute: just use ‘as.POSIXlt’ and extract the relevant
     component.

(d <- Sys.Date())
1900 + as.POSIXlt(d)$year
1 + as.POSIXlt(d)$mon

should get you started.

On Tue, 27 Oct 2009, [email protected] wrote:

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

--
Brian D. Ripley,                  [email protected]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595
______________________________________________
[email protected] 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