[R] Time alignment of time series

Fernando Saldanha fsaldan1 at gmail.com
Tue Apr 26 02:10:56 CEST 2005


One thing that has given me trouble is the fact that the time series
implementation in the class ts relies on the concept of a "start" to
the time series. For example, if I have

ts1 <- ts(c(1,2,3))

dts1 <- diff(ts1)

then dts1 will be a vector c(1,1) but with the attribute start = 2.

Similarly, when one takes lags the "start" is moved around and the
underlying vector itself is left untouched.

Now, data frames seem to be able to deal with this. That is, if I do
regressions involving these time series objects the data is correctly
aligned. However, for some functions, like for example pairs() the
data is misaligned. For example, if I call pairs with a series and
itself lagged once and twice as the three arguments I only get points
in the diagonals. The start attribute is ignored.

Is there a simple way to avoid this problem? That is, is there a way
to keep the data aligned by having functions take the start attribute
into account?

Thanks for any help.

FS




More information about the R-help mailing list