[R] Lag Function

Downey, Patrick PDowney at urban.org
Mon Mar 22 17:15:27 CET 2010


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

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

Thank you,
Mitch 



More information about the R-help mailing list