[R] Zoo changing time-zone when I merge 2 zoo time series

Eric Berger er|cjberger @end|ng |rom gm@||@com
Mon Jul 9 14:19:50 CEST 2018


I found the following at
https://stackoverflow.com/questions/25269425/merge-zoo-removes-time-zone

library(xts)

merge2=function(x,y) {
  as.zoo(merge(as.xts(x), as.xts(y)))}

If you define the function merge2() as above then

merge2(Dat1,Dat2)

should be ok

HTH,
Eric


On Mon, Jul 9, 2018 at 1:22 PM, Christofer Bogaso <
bogaso.christofer using gmail.com> wrote:

> Hi,
>
> Below is my code :
>
> library(zoo)
> Dat1 = structure(c(17890, 17770.01, 17600, 17593, 17630.01), index =
> structure(c(1512664740,
> 1512664800, 1512664860, 1512664920, 1512664980), class = c("POSIXct",
> "POSIXt"), tzone = "America/Los_Angeles"), class = "zoo")
> Dat2 = structure(c(15804.28, 15720.61, 15770, 15750, 15770), index =
> structure(c(1512664740,
> 1512664800, 1512664860, 1512664920, 1512664980), class = c("POSIXct",
> "POSIXt"), tzone = "America/Los_Angeles"), class = "zoo")
>
> merge(Dat1, Dat2)
>
>                         Dat1     Dat2
> 2017-12-07 22:09:00 17890.00 15804.28
> 2017-12-07 22:10:00 17770.01 15720.61
> 2017-12-07 22:11:00 17600.00 15770.00
> 2017-12-07 22:12:00 17593.00 15750.00
> 2017-12-07 22:13:00 17630.01 15770.00
>
>
> So, after merging the TZ of the original series got changed.
>
> Appreciate if someone points what went wrong
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

	[[alternative HTML version deleted]]




More information about the R-help mailing list