[R] Class for time of day?
ggrothendieck at gmail.com
Wed May 20 18:28:57 CEST 2009
There is a times class in the chron package. Times are measured
in fractions of a day so 1/24 is one hour.
> dt <- Sys.time()
> tt <- times(format(dt, "%H:%M:%S"))
> tt + 1/24
There is an article on dates and times in R News 4/1.
On Wed, May 20, 2009 at 10:57 AM, Stavros Macrakis
<macrakis at alum.mit.edu> wrote:
> What is the recommended class for time of day (independent of calendar
> And what is the recommended way to get the time of day from a POSIXct
> object? (Not a string representation, but a computable representation.)
> I have looked in the man page for DateTimeClasses, in the Time Series
> Analysis Task View and in Spector's Data Manipulation book but haven't found
> these. Clearly I can create my own Time class and hack around with the
> internal representation of POSIXct, e.g.
> days <- unclass(d)/(24*3600)
> and write print.Time, `-.Time`, etc. etc. but I expect there is already a
> standard class or CRAN package.
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help