lagvec {onlineforecast}R Documentation

Lag by shifting

Description

Lag by shifting the vecter

Usage

lagvec(x, lag)

Arguments

x

The vector to lag

lag

(integer) The steps to lag.

Details

A positive value of lag shifts the values to the right in the vector.

Value

The shifted vector

Examples


# 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)


[Package onlineforecast version 1.0.2 Index]