Hallo everyone I have two univariate time series (class ts) describing the same variable. They have the same resolution, but span different periods in time with a big gap in between. I need to append one to the other such that they are one object, with the gap filled with NAs. The method ts.union produces a multivariate time series where the time axis is correct, but the individual time series are not combined into one. Thanks a lot for a reply, Jörg Dr. Jörg Klausen phone : +41 (0)44 823 41 27 EMPA (134)/GAW/QA-SAC fax : +41 (0)44 821 62 44 Überlandstrasse 129 mailto: joerg.klausen@empa.ch CH-8600 Dübendorf http://www.empa.ch/gaw Switzerland http://www.empa.ch/gaw/gawsis [[alternative HTML version deleted]]
On Wed, 13 Apr 2005, Joerg Klausen wrote:> I have two univariate time series (class ts) describing the same > variable. They have the same resolution, but span different periods in > time with a big gap in between. I need to append one to the other such > that they are one object, with the gap filled with NAs. The method > ts.union produces a multivariate time series where the time axis is > correct, but the individual time series are not combined into one.Use window() to create an extended series, then indexing to insert the other in the correct place. E.g. x1 <- ts(1:10, start=1900) x2 <- ts(70:80, start=1970) xx <- window(x1, end=1980, extend=TRUE) xx[71:81] <- x2 -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
On 4/13/05, Joerg Klausen <Joerg.Klausen at empa.ch> wrote:> Hallo everyone > > I have two univariate time series (class ts) describing the same variable. They have the same resolution, but span different periods in time with a big gap in between. I need to append one to the other such that they are one object, with the gap filled with NAs. The method ts.union produces a multivariate time series where the time axis is correct, but the individual time series are not combined into one. >If ts1 and ts2 are two ts series: both <- ts.union(ts1, ts2) pmax(both[,1], both[,2], na.rm = TRUE)