a296180@mica.fmr.com
2002-May-21 20:17 UTC
[Rd] I() fails on objects of class POSIXct (PR#1587)
Although the documentation is somewhat sketchy, I() can be used to create objects of class AsIs:> I("a")[1] "a" attr(,"class") [1] "AsIs" "character"> I(4)[1] 4 attr(,"class") [1] "AsIs" "numeric"> I(4 + 0i)[1] 4+0i attr(,"class") [1] "AsIs" "complex">This fails for objects of class POSIXct.> class(ISOdate(2002, 5, 21))[1] "POSIXt" "POSIXct"> I(ISOdate(2002, 5, 21))Error in names(x) : evaluation is nested too deeply: infinite recursion?>Interestingly enough, it produces an (incorrect?) answer for objects of class POSIXlt> class(as.POSIXlt(ISOdate(2002, 5, 21)))[1] "POSIXt" "POSIXlt"> I(as.POSIXlt(ISOdate(2002, 5, 21)))[1] " 0" " 0" " 8" " 21" " 4" "102" " 2" "140" " 1">Of course, this may not be a bug since it is not clear that I() is documented to do anything like this.> R.version_ platform sparc-sun-solaris2.6 arch sparc os solaris2.6 system sparc, solaris2.6 status major 1 minor 5.0 year 2002 month 04 day 29 language R Regards, David Kane -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Peter Dalgaard BSA
2002-May-21 20:48 UTC
[Rd] I() fails on objects of class POSIXct (PR#1587)
a296180@mica.fmr.com writes:> Although the documentation is somewhat sketchy, I() can be used to create > objects of class AsIs:...> This fails for objects of class POSIXct. > > > class(ISOdate(2002, 5, 21)) > [1] "POSIXt" "POSIXct" > > I(ISOdate(2002, 5, 21)) > Error in names(x) : evaluation is nested too deeply: infinite recursion? > >Actually I() works fine, but the resulting object has a print method problem:> x <- I(ISOdate(2002, 5, 21)) > xError in names(x) : evaluation is nested too deeply: infinite recursion?> dput(x)structure(1021982400, class = c("AsIs", "POSIXt", "POSIXct")) Looks like the issue is that print calls format.AsIs which calls toString which calls paste which calls as.character which calls format which.... ----> Interestingly enough, it produces an (incorrect?) answer for objects of class > POSIXlt > > > class(as.POSIXlt(ISOdate(2002, 5, 21))) > [1] "POSIXt" "POSIXlt" > > I(as.POSIXlt(ISOdate(2002, 5, 21))) > [1] " 0" " 0" " 8" " 21" " 4" "102" " 2" "140" " 1" > >However, that is not particularly incorrect:> dput(as.POSIXlt(ISOdate(2002, 5, 21)))structure(list(sec = 0, min = 0, hour = 14, mday = 21, mon = 4, year = 102, wday = 2, yday = 140, isdst = 1), .Names = c("sec", "min", "hour", "mday", "mon", "year", "wday", "yday", "isdst" ), class = c("POSIXt", "POSIXlt"), tzone = c("", "CET", "CEST" )) (Notice the 6hr time diff..) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Apparently Analagous Threads
- given a mid-month date, get the month-end date
- ISOdate/ISOdatetime performance suggestions, other date/time questions
- isdst
- Wrong length of POSIXt vectors (PR#10507)
- The presence/absence of `zone` in POSIXlt depending on time zone as a cause of possible inconsistences?