Here is one way that does not require explicit assignment of tzone:
rbind(data.frame(x=xx), data.frame(x=xx[1] - 60), data.frame(x=xx[2] + 60))[[1]]
With xx from the post we get:
rbind(data.frame(x=xx), data.frame(x=xx[1] - 60), data.frame(x=xx[2] +
60))[[1]]
[1] 2006-09-26 12:00:00 GMT 2006-09-26 13:00:00 GMT
[3] 2006-09-26 11:59:00 GMT 2006-09-26 13:01:00 GMT
On 9/27/06, Sebastian P. Luque [EMAIL PROTECTED] wrote:
Hello,
What is the best way to concatenate POSIXct objects keeping the time zone
attribute in a program? For example:
R xx - as.POSIXct(strptime(c(2006-09-26 12:00:00, 2006-09-26 13:00:00),
+ format=%Y-%m-%d %H:%M:%S), tz=GMT)
R xx
[1] 2006-09-26 12:00:00 GMT 2006-09-26 13:00:00 GMT
but, as ?c.POSIXct explains:
R c(xx, xx[1] - 60, xx[2] + 60)
[1] 2006-09-26 07:00:00 CDT 2006-09-26 08:00:00 CDT
[3] 2006-09-26 06:59:00 CDT 2006-09-26 08:01:00 CDT
Is there something better/safer than simply setting the tzone attribute
of the new object?
Cheers,
--
Seb
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.