Spencer Graves
2012-Jul-09 04:46 UTC
[R] c(a, b) for POSIXct objects with tzone attributes?
Hello: 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 inthe 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? Thanks, Spencer -- 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
Spencer: Just for fun, may I hazard a guess: It would be messy to retain time zones if your were concatenating objects with more than one time zone among them. "Normalizing" everything to a single zone probably also makes subsequent operations on the results much easier. Not that it couldn't be done -- and maybe already has been in some package. If so, I would bet it's done via S4 classes, which would seem to be a natural way to go. Hopefully, you'll get a more informed and authoritative explanation, though. ... I'm just speculating and and may be all wet. Cheers, Bert On Sun, Jul 8, 2012 at 9:46 PM, Spencer Graves < spencer.graves@structuremonitoring.com> wrote:> Hello: > > > 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? > > > Thanks, > Spencer > > -- > 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 > > ______________________________**________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help> > PLEASE do read the posting guide http://www.R-project.org/** > posting-guide.html <http://www.R-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >-- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[alternative HTML version deleted]]