[Rd] New errors with difftime()-objects in 2.11.1 (was Re: Request: difftime method for cut())
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. 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. -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [R] New errors with difftime()-objects in 2.11.1 (was Re: Request: difftime method for cut())
On Tue, Jun 22, 2010 at 7:50 PM, David Winsemius wrote: > > On Jun 22, 2010, at 1:33 PM, Gustaf Rydevik wrote: > 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." > > > David Winsemius, MD > West Hartford, CT > > Oh, I forgot to mention that the workaround of using as.double (or as.numeric) works fine, and I've done that. It's just that it can take quite a while (as in several hours) to figure out that the reason for the error is that you have to force difftime objects to be numeric in 2.11.1, when the code's been working fine before and the error messages are obscure. Regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [R] New errors with difftime()-objects in 2.11.1 (was Re: Request: difftime method for cut())
On Wed, Jun 23, 2010 at 7:13 AM, Peter Dalgaard wrote: > Gustaf Rydevik wrote: > >> Oh, I forgot to mention that the workaround of using as.double (or >> as.numeric) works fine, and I've done that. >> It's just that it can take quite a while (as in several hours) to >> figure out that the reason for the error is that you have to force >> difftime objects to be numeric in 2.11.1, when the code's been working >> fine before and the error messages are obscure. > > I don't think you realize the problems that could occur by assuming that > difftime objects are numerics ON ANY PARTICULAR SCALE! > > -- > Peter Dalgaard > Center for Statistics, Copenhagen Business School > Phone: (+45)38153501 > Email: pd@cbs.dk Priv: pda...@gmail.com > Ah. Yes, you're right that it would be problematic to say the least to assume that the difftime object is measured in days and not in, say, seconds. And I suppose that it makes sense to prioritize avoiding calculations that give misleading results over forcing changes in old code. I was just caught somewhat unprepared, and I know that my colleagues who is not quite as R-literate will be even more unprepared for old stuff no longer working. Usually, R prepares the user for these kind of things by throwing warnings a version or two before the change is actually implemented. But I guess that's not always practical. I take it that your argument would also work agains implementing simple difftime-methods of functions as well, where you force difftime objectws to be numeric? In that case, people can disregard my suggestion of adding a difftime-method to cut(). Anyhow, I'll stop whining now. Thanks for the good work you're doing in the R Core team. Regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Request: difftime method for cut()
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 -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] tiff() causes R to crash on WinXP (PR#11804)
Full_Name: Gustaf Rydevik Version: 2.7.1 OS: Win XP professional Submission from: (NULL) (130.237.97.254) The following lines of code crash R 2.7.1 (=cause R to show "The R gui has encountered a problem and needs to close"). Replicated on two WinXp professional machines, as well as by Uwe Ligges. > sessionInfo() R version 2.7.1 (2008-06-23) i386-pc-mingw32 locale: LC_COLLATE=Swedish_Sweden.1252;LC_CTYPE=Swedish_Sweden.1252;LC_MONETARY=Swedish_Sweden.1252;LC_NUMERIC=C;LC_TIME=Swedish_Sweden.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] boot_1.2-33lattice_0.17-8 nlme_3.1-89RWinEdt_1.8-0 loaded via a namespace (and not attached): [1] grid_2.7.1 tools_2.7.1 >tiff() >plot(1:1000) >dev.off() __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel