Re: [R] Class for time of day?

2009-05-22 Thread Stavros Macrakis
On Thu, May 21, 2009 at 8:28 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: It uses hours/minutes/seconds for values 1 day and uses days and fractions of a day otherwise. Yes, my examples were documenting this idiosyncracy. For values and operations that it has not considered it

Re: [R] Class for time of day?

2009-05-22 Thread Gabor Grothendieck
You could create a subclass of times with its own print and format methods that printed and formatted hours/minutes/seconds even if greater than one day if that is the main item you need. Regarding division you could contribute that to the chron package. I've contributed a few missing items and

Re: [R] Class for time of day?

2009-05-22 Thread Stavros Macrakis
On Fri, May 22, 2009 at 10:03 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Regarding division you could contribute that to the chron package. I've contributed a few missing items and they were incorporated. Good to know. Maybe I'll do that Giving an error when it does not

Re: [R] Class for time of day?

2009-05-22 Thread Gabor Grothendieck
On Fri, May 22, 2009 at 11:01 AM, Stavros Macrakis macra...@alum.mit.edu wrote: On Fri, May 22, 2009 at 10:03 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Regarding division you could contribute that to the chron package. I've contributed a few missing items and they were

Re: [R] Class for time of day?

2009-05-22 Thread Stavros Macrakis
On Fri, May 22, 2009 at 12:28 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: ...The way this might appear in code is if someone wanted to calculate the number of one hour intervals in 18 hours. One could write: t18 - times(18:00:00) t1 - times(1:00:00) as.numeric(t18) /

Re: [R] Class for time of day?

2009-05-22 Thread Gabor Grothendieck
On Fri, May 22, 2009 at 1:55 PM, Stavros Macrakis macra...@alum.mit.edu wrote: On Fri, May 22, 2009 at 12:28 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: ...The way this might appear in code is if someone wanted to calculate the number of one hour intervals in 18 hours.  One could

Re: [R] Class for time of day?

2009-05-21 Thread Stavros Macrakis
On Wed, May 20, 2009 at 12:28 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: There is a times class in the chron package. Perfect! Just what I was looking for. On Wed, May 20, 2009 at 12:19 PM, jim holtman jholt...@gmail.com wrote: If you want the hours from a POSIXct, here is one

Re: [R] Class for time of day?

2009-05-21 Thread Gabor Grothendieck
On Thu, May 21, 2009 at 5:04 PM, Stavros Macrakis macra...@alum.mit.edu wrote: On Wed, May 20, 2009 at 12:28 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: There is a times class in the chron package. Perfect!  Just what I was looking for. On Wed, May 20, 2009 at 12:19 PM, jim

[R] Class for time of day?

2009-05-20 Thread Stavros Macrakis
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

Re: [R] Class for time of day?

2009-05-20 Thread Gabor Grothendieck
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

Re: [R] Class for time of day?

2009-05-20 Thread jim holtman
If you want the hours from a POSIXct, here is one way of doing it; you can create a function for doing it: x - Sys.time() x [1] 2009-05-20 12:17:13 EDT y - difftime(x, trunc(x, units='days'), units='hours') y Time difference of 12.28697 hours as.numeric(y) [1] 12.28697 It depends on what