Learn R Programming

onlineforecast (version 0.9.3)

lagvec: 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.

Value

The shifted vector

Details

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

Examples

Run this code
# NOT RUN {
# 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)

# }

Run the code above in your browser using DataLab