Dear R-helpers, In my data set, I have a time variable 'RecordTime' whose class property is 'times'. When I list my data set, I see the values of RecordTime is like 10:20:30 in a 'h:m:s' format. Suppose I want to choose all the data after 10 o'clock, then use subset(data,RecordTime>10:20:30) just doesn't work. I noticed that all the values of RecordTime seem to take some decimals when using str(data). But how can I easily find the correspondence between those decimals and the exact times? I have looked at the help file of POSIXlt and related functions. Yet I couldn't find any useful instruction on this issue.
Gabor Grothendieck
2005-Jul-17 18:35 UTC
[R] Where to learn how to deal with time class variable?
On 7/17/05, Kerry Bush <kerryrekky at yahoo.com> wrote:> Dear R-helpers, > In my data set, I have a time variable 'RecordTime' > whose class property is 'times'. When I list my data > set, I see the values of RecordTime is like 10:20:30 > in a 'h:m:s' format. Suppose I want to choose all the > data after 10 o'clock, then use > > subset(data,RecordTime>10:20:30) > > just doesn't work. I noticed that all the values of > RecordTime seem to take some decimals when using > str(data). But how can I easily find the > correspondence between those decimals and the exact > times? I have looked at the help file of POSIXlt and > related functions. Yet I couldn't find any useful > instruction on this issue.Are you using the chron library? Assuming that is the case, you want to make sure that the object you are comparing your times object to is also a times object:> library(chron) > example(chron) # this defines a times object tms (output omitted) > tms[1] 23:03:20 22:29:56 01:03:30 18:21:03 16:56:26> subset(tms, tms > times("20:00:00"))[1] 23:03:20 22:29:56
Maybe Matching Threads
- How to manipulate the time data without the date?
- Problems with date-format (R 2.1.1 + chron)
- Function that is giving me a headache- any help appreciated (automatic read )
- Questions about doing analysis based on time
- ggplot2 applying a function based on facet