Re: [Rd] Date vs date

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

> > 3. temp <- as.Date('1990/1/1') - as.date('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



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel 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 https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.