Lag a vector
This function computes a lagged vector, shifting it back or forward.
lagk(x, k, na = FALSE, cst = FALSE)
| x | A vector. | 
| k | integer. The number of lags. 
If  | 
| na | logical. If  | 
| cst | logical. 
If  | 
A vector of the same type and length as x.
v <- sample(1:10) print(v) lagk(v, 1) lagk(v, 1, na = TRUE) lagk(v, -2) lagk(v, -3, na = TRUE) lagk(v, -3, na = FALSE, cst = TRUE) lagk(v, -3, na = FALSE)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.