Gabor Grothendieck <ggrothendieck <at> gmail.com> writes:
> 
> Here are three ways:
> 
> xx <- as.Date("2006-01-05")
> 
> # 1. use as.POSIXlt
> as.POSIXlt(xx)$mday
> as.POSIXlt(xx)$mon + 1
> as.POSIXlt(xx)$year + 1900
> 
> # 2. use format
> as.numeric(format(xx, "%d"))
> as.numeric(format(xx, "%m"))
> as.numeric(format(xx, "%Y"))
> 
> # 3. use month.day.year in chron package
> library(chron)
> month.day.year(unclass(xx))$day
> month.day.year(unclass(xx))$month
> month.day.year(unclass(xx))$year

Hi,

it would really be great if there would be

sec(), min(), hour() day(), month(), year()

generic functions that would work on all "date" classes. Where
applicable of course. I imagine that argument to get out integer
or character would alse be nice.

Gregor

______________________________________________
[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