An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111126/2f4ac83e/attachment.pl>
Time series merge?
4 messages · Kevin Burton, Gabor Grothendieck, Hasan Diwan
On Sat, Nov 26, 2011 at 10:55 AM, Kevin Burton <rkevinburton at charter.net> wrote:
I have two time series a <- ts(1:10, start=c(1,6), end=c(2,5), frequency=10) b <- ts(1:5, start=c(2,1), end=c(2,5), frequency=10) Obviously 'b' is a subset of 'a'. I want a single index value indicating where that start of 'b' lines up with the start of 'a'. So in this simple example I would expect an index of 5. I was playing with 'merge'. But, for a 'ts' object this does not produce anything that is useful:
merge(a,b)
Try this: library(zoo) m <- merge(a = as.zoo(a), b = as.zoo(b)) m or to get a ts object back: as.ts(m)
Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
Seems to work fine. Thank you. -----Original Message----- From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com] Sent: Saturday, November 26, 2011 10:11 AM To: Kevin Burton Cc: r-help at r-project.org Subject: Re: [R] Time series merge? On Sat, Nov 26, 2011 at 10:55 AM, Kevin Burton <rkevinburton at charter.net> wrote:
I have two time series a <- ts(1:10, start=c(1,6), end=c(2,5), frequency=10) b <- ts(1:5, start=c(2,1), end=c(2,5), frequency=10) Obviously 'b' is a subset of 'a'. I want a single index value indicating where that start of 'b' lines up with the start of 'a'. So in this simple example I would expect an index of 5. I was playing with 'merge'. But, for a 'ts' object this does not produce anything that
is useful:
merge(a,b)
Try this: library(zoo) m <- merge(a = as.zoo(a), b = as.zoo(b)) m or to get a ts object back: as.ts(m) -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111126/bc499da5/attachment.pl>