[R] c(a, b) for POSIXct objects with tzone attributes?

Spencer Graves spencer.graves at structuremonitoring.com
Mon Jul 9 06:46:09 CEST 2012


       What is the recommended method for retaining the tzone attributes 
when concatonating POSIXct objects?

> (d1 <- ISOdate(1970,1,1)) # Sets the tzone attribute = GMT
[1] "1970-01-01 12:00:00 GMT"
> (d1.2 <- c(d1, d1)) # c(..) strips the tzone attribute, displays in
the time zone of the operating system
[1] "1970-01-01 04:00:00 PST" "1970-01-01 04:00:00 PST"
> attr(d1.2, 'tzone') <- 'GMT'
> d1.2 # tzone attribute manually restored
[1] "1970-01-01 12:00:00 GMT" "1970-01-01 12:00:00 GMT"

       "c" is a generic function with a method defined for objects of 
class POSIXct, so the results here were what is returned by c.POSIXct 
[as discussed with help('c.POSIXct')].

       Is there some other function like "c2", say, that tries to retain 
attributes where "c" strips all but names?


Spencer Graves, PE, PhD
President and Chief Technology Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567
web:  www.structuremonitoring.com

More information about the R-help mailing list