[R] Unexpected behavior with cbind.ts

Caio Guimarães Figueiredo apoema.asa at gmail.com
Wed Aug 10 19:54:38 CEST 2016


I got two ts variables (w and y) that I want to cbind into a mts matrix
variable.

w is a simple ts object with some random data, length=40, start = 2005, end
= 2014.75, frequency = 4, class = "ts".

y is a collection of 2 ts, nrow = 40, ncol=2, start = 2005, end = 2014.75,
frequency = 4, class = "mts", "ts", "matrix"

I was expecting that the result of cbind(w,y) to be a mts matrix with 3
columns, 40 rows, same start and frequency as the originals, and finally to
be of class "mts", "ts", "matrix.

What I get is a single ts variable with length = 120, start = 2005 but end
= 2034,75, frequency = 4, class = "ts". This behavior is what i would
expect from ts.union, but not from cbind.

I, unsuccessfully,  tried to replicated this result with different
variables. For example, cbind(ts(c(0,1), ts(matrix(c(2,3,4,5), 2,2))),
returns exactly what I was expecting a ts matrix, with 2 rows and 3 columns.

Anyone has any idea of what is happening? What kind of attribute my
variables could have to imply this behavior? I have the felling that I am
simply calling two different function, but don't know why.

Thank you in advance

	[[alternative HTML version deleted]]



More information about the R-help mailing list