lagk {statip} | R Documentation |
Lag a vector
Description
This function computes a lagged vector, shifting it back or forward.
Usage
lagk(x, k, na = FALSE, cst = FALSE)
Arguments
x |
A vector. |
k |
integer. The number of lags.
If |
na |
logical. If |
cst |
logical.
If |
Value
A vector of the same type and length as x
.
Examples
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)
[Package statip version 0.2.3 Index]