lagvec | R Documentation |
Lag by shifting the vecter
lagvec(x, lag)
x |
The vector to lag |
lag |
(integer) The steps to lag. |
A positive value of lag
shifts the values to the right in the vector.
The shifted vector
# The values are simply shifted
# Ahead in time
lagvec(1:10, 3)
# Back in time
lagvec(1:10, -3)
# Works but returns a numric
lagvec(as.factor(1:10), 3)
# Works and returns a character
lagvec(as.character(1:10), 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.