Re: [R] New errors with difftime()-objects in 2.11.1 (was Re: Request: difftime method for cut())

From: David Winsemius <>
Date: Tue, 22 Jun 2010 13:50:15 -0400

On Jun 22, 2010, at 1:33 PM, Gustaf Rydevik wrote:

> On Thu, Jun 10, 2010 at 3:39 PM, Gustaf Rydevik
> <> wrote:
>> Hi all,
>> The recent change in 2.11 that made as.numeric() return false on
>> difftime-objects broke some of my code that calculated age classes of
>> individuals using cut(). While this was no big thing to fix for me,
>> it
>> might be wise
>> to provide a cut.difftime method to stop other old code from
>> breaking.
>> I'm guessing something as simple as
>> cut.difftime<-function(x,...){
>> x<-as.numeric(x)
>> cut(x,...)
>> }
>> would suffice.
>> best regards,
>> Gustaf
> As a followup, the change in how to treat difftime objects break even
> more of my old code in a different project, since I'm used to treating
> difftime as numeric in regressions and other analysis.
> And the error messages become *very* obscure, I.e "Error: NA/NaN/Inf
> in foreign function call (arg 2)" when applying loess to a difftime
> object. Tracking down the source of those errors become quite a
> nuisance.
> I suppose there's no chance of reversing the change, but I'd
> appreciate if someone could tell me the reason for introducing it so
> abrubtly.

Cannot help you there, but have you looked at the help page for difftime?

"The as.double method returns the numeric value expressed in the specified units. Using units = "auto" means the units of the object."

> I'm cc'ing this to R-help, since there's probably more people than me
> that will be bitten by this in the future when looking into old
> projects.
> Regards,
> Gustaf Rydevik.

David Winsemius, MD
West Hartford, CT mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Tue 22 Jun 2010 - 17:52:48 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 Tue 22 Jun 2010 - 18:20:34 GMT.

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

list of date sections of archive