Skip to content
Prev 30660 / 63424 Next

timezone attribute lost

All of those problems are due to a problem in unique.default(), which
sends
the integer data in POSIXct, Date, and factor objects through a
.Internal
and then tries to reconstruct the original sort of object from the
integer output of that .Internal()
    z <- .Internal(unique(x, incomparables, fromLast))
    if (is.factor(x))
        factor(z, levels = seq_len(nlevels(x)), labels = levels(x),
            ordered = is.ordered(x))
    else if (inherits(x, "POSIXct") || inherits(x, "Date"))
        structure(z, class = class(x))

Your immediately problem could be solved by adding tzone=attr(x,"tzone")
to the structure call, but I'm not familiar enough with classes
inheriting
from POSIXct and Date to know if that is sufficient.  There is no reason
someone won't make a new subclass where another attribute is essential.
Since .Internal used the equivalent of as.numeric(x) to extract numeric
codes,
it might be nice to have an as.numeric<-(x,value) function that could
insert
numeric codes back into a dataset so you could avoid reconstructing an
object
of unknown structure with as.numeric(x)<-z (or perhaps as.vector<-
should
be used so you don't have to know what the integer type is).  In S and
S+
one can use x at .Data<-newNumericCodes for this sort of thing, but that
can
be dangerous because it lets you stick in inappropriate types.
 
One might think that adding a new unique method for POSIXct or Date or
things
subclassed from them would be the right way to structure things, but
factor()
explicitly calls unique.default().
Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com