Day of the Week, Month, Year, Week of the Year in R
r
Solution
You get a few of those just from `POSIXlt`, with its weird convention. Year needs to 1900, month is on the 0 to 11 range -- but you do get weekday and day-of-the-year.
R> dd <- as.Date("2012-05-03")
R> as.POSIXlt(dd)
[1] "2012-05-03 UTC"
Then
R> unclass(as.POSIXlt(dd))
$sec
[1] 0
$min
[1] 0
$hour
[1] 0
$mday
[1] 3
$mon
[1] 4
$year
[1] 112
$wday
[1] 4
$yday
[1] 123
$isdst
[1] 0
attr(,"tzone")
[1] "UTC"
R>
Problem
Are there any built on functions that can be used on a data frame object to generate variables on a class `Date` time series to create day of the Week, Month, Year, Week of the Year, etc in R? The `weekdays`, `months`, `quarters`, functions in the base package generate text output, looking for numerical output to denote that 3/5/2012, for example, is a Friday, 3rd day of the month, 1 week of the month, and the 63 day of the year, etc.