Re: [Rd] Date vs date

From: hadley wickham <>
Date: Fri, 14 Sep 2007 16:19:44 -0500

> > 3. temp <- as.Date('1990/1/1') -'1953/2/5')
> > sqrt(temp)
> > Error in Math.difftime(temp3) : sqrtnot defined for "difftime" objects
> >
> > Minor bug: no space before the word 'not'
> > Major: this shouldn't fail.
> >
> >
> Arguably, it should (Is this a difftime object? Which units?).
> I'd advise against numeric operation on difftime objects in general,
> because of the unspecified units. These are always "days" when working
> with Date objects, but with general time objects it is not predictable.
> So I'd recommend sqrt(as.numeric(temp, units="days")).

Why not just always use seconds for difftime objects? An attribute could control how it was formatted, but would be independent of the underlying representation.

Hadley mailing list Received on Fri 14 Sep 2007 - 21:22:16 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 15 Sep 2007 - 08:41:00 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.