[R] Combine univariate time series

Gabor Grothendieck ggrothendieck at gmail.com
Wed Apr 13 14:01:06 CEST 2005


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)




More information about the R-help mailing list