Assuming they are of the same length try this:
> library(zoo)
> # test data
> A <- zoo(1:3, Sys.Date() + 1:3)
> B <- zoo(4:6, Sys.Date() + 14:16)
>
> time(A) <- time(B)
> A
2010-04-22 2010-04-23 2010-04-24
1 2 3
Next time please provide test data with your post.
On Thu, Apr 8, 2010 at 10:35 AM, Research <risk2009 at ath.forthnet.gr>
wrote:> Hi,
>
> I have two zoo objects (time series of same frequency) say A and B. I need
> to exchange A's dates for B's.
>
> Is there and easy way?
>
> I managed to do it by converting A to a vector and pasting it on a ? zoo
> vector (all ones) with B's dates but I wonder if there is an easier
?way by
> some "zoo" command ?I have overlooked...
>
> Thanks in advance,
> Costas
>
> ______________________________________________
> R-help at r-project.org 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.
>