Helper function to create a lagged version of a vector.

lagged(x, k)

Arguments

x

a vector

k

the lag to use

Value

A lagged version of the vector

Examples

lagged(1:10, 1)
#> [1] NA 1 2 3 4 5 6 7 8 9
lagged(1:10, -1)
#> [1] 2 3 4 5 6 7 8 9 10 NA
lagged(1:10, 0)
#> [1] 1 2 3 4 5 6 7 8 9 10