There is a times class in the chron package. Times are measured in fractions of a day so 1/24 is one hour.
> library(chron) > dt <- Sys.time() > tt <- times(format(dt, "%H:%M:%S")) > tt [1] 12:27:46 > tt + 1/24 [1] 13:27:46 There is an article on dates and times in R News 4/1. On Wed, May 20, 2009 at 10:57 AM, Stavros Macrakis <macra...@alum.mit.edu> wrote: > What is the recommended class for time of day (independent of calendar > date)? > > 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) > days-floor(days) > > and write print.Time, `-.Time`, etc. etc. but I expect there is already a > standard class or CRAN package. > > -s > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org 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. > ______________________________________________ R-help@r-project.org 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.