[R] c() with POSIXlt objects and their timezone is lost

Marc Girondot marc_grt at yahoo.fr
Mon Jun 23 23:52:07 CEST 2014


When two POSIXlt objects are combine with c(), they lost their tzone 
attribute, even if they are the same.
I don't know if it is a feature, but I don't like it !

Marc

 > es <- strptime("2010-02-03 10:20:30", format="%Y-%m-%d %H:%M:%S", 
tz="UTC")
 > es
[1] "2010-02-03 10:20:30 UTC"
 > attributes(es)
$names
[1] "sec"   "min"   "hour"  "mday"  "mon"   "year"  "wday"  "yday" "isdst"

$class
[1] "POSIXlt" "POSIXt"

$tzone
[1] "UTC"

 > c(es, es)
[1] "2010-02-03 11:20:30 CET" "2010-02-03 11:20:30 CET"
 > attributes(c(es, es))
$names
  [1] "sec"    "min"    "hour"   "mday"   "mon"    "year"   "wday" 
"yday"   "isdst"  "zone"   "gmtoff"

$class
[1] "POSIXlt" "POSIXt"

$tzone
[1] ""     "CET"  "CEST"



More information about the R-help mailing list