lagvec: Lag by shifting

View source: R/lagvec.R

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


onlineforecast documentation built on Oct. 12, 2023, 5:15 p.m.