[R] How to manipulate the time data without the date?

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Fri Nov 7 09:32:31 CET 2008

2008/11/7 tedzzx <zengzhenxing at gmail.com>:
> The problem is that: There is some rounding problems, for example
> Library(chron)
> any(times("4:00:01")==times("4:00:00")+times("00:00:01")))
> False
> But,it should be true

 FAQ 7.31 in disguise!

 chron stores date-times as fractions, so you're comparing two
floating point numbers here. FAQ 7.31 applies.

 Use 'all.equal', which has a method for chron that uses a 1 second
tolerance to match times:

> all.equal(times("4:00:01"),times("4:00:00")+times("00:00:01"))
[1] TRUE


More information about the R-help mailing list