[R] New errors with difftime()-objects in 2.11.1 (was Re: Request: difftime method for cut())
David Winsemius
dwinsemius at comcast.net
Tue Jun 22 19:50:15 CEST 2010
On Jun 22, 2010, at 1:33 PM, Gustaf Rydevik wrote:
> On Thu, Jun 10, 2010 at 3:39 PM, Gustaf Rydevik
> <gustaf.rydevik at gmail.com> 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
More information about the R-help
mailing list