Hello,

Downey, Patrick wrote:
Can anyone tell me what's going on here?

x <- matrix(data=c(1,2,3,4,5),ncol=1)
x1 <- lag(x,k=1)
x
x1
x - x1

That's with x specified as a column vector, but the same thing happens when
it's a row vector.

x <- c(1,2,3,4,5)
x1 <- lag(x,k=1)
x
x1
x - x1


I'm not sure what you're expecting to happen. Can you clarify what needs explaining? My guess is that the 'lag' function is not doing what you expect, but you don't say what you expect.


When the documentation says "Vector or matrix arguments x are coerced to
time series." What does that mean?

Time series are a class of objects in R, it means if you don't pass the lag function a time series object, it's going to try to turn it into one.

______________________________________________
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.

Reply via email to