Try xts (tsObj, order.by=index (tsobj)) On Nov 26, 2011 10:57 AM, "Kevin Burton" <rkevinbur...@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) > > x > > 1 1 > > 2 2 > > 3 3 > > 4 4 > > 5 5 > > > > I get the same answer if I use 'merge(b,a)' so I don't know how to convert > this result to something useful. So then I decided to use 'xts'. But the > conversion fails: > > > > > ax <- as.xts(a) > > Error in as.xts.ts(a) : could not convert index to appropriate type > > > > For this simple example I could code it myself using a simple for loop but > if I add capability to handle missing dates, different frequencies, etc. it > gets complicated very fast. It seems that 'xts' has more extensive date > handling facilities that 'ts' but I am stuck since it doesn't look like I > can convert from 'ts' to 'xts'. > > > > Thanks in advance for your suggestions. > > > > Kevin > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. > [[alternative HTML version deleted]] ______________________________________________ R-help@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.