From p.dalgaard@biostat.ku.dk  Tue May 21 21:48:27 2002
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 21 May 2002 22:48:27 +0200
Subject: [Rd] I() fails on objects of class POSIXct (PR#1587)
In-Reply-To: <200205212017.WAA09766@pubhealth.ku.dk>
References: <200205212017.WAA09766@pubhealth.ku.dk>
Message-ID: <x2bsb94484.fsf@blueberry.kubism.ku.dk>

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))
> x
Error 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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] I() fails on objects of class POSIXct (PR#1587)
Peter Dalgaard BSA