Learn R Programming

linea (version 0.1.1)

lag: Lag

Description

Lag by l

Usage

lag(v, l, strategy = "extremes")

Value

The lagged vector v

Arguments

v

Numeric vector

l

Lag as an integer

strategy

string to determine the NAs generated by the lag should be filled with zeros or with the extremities' values

Details

Applies a lag of l on the input vector, v

Examples

Run this code
lag(c(1,0,0,0,1,0,0,0,2), 1)
lag(c(1,0,0,0,1,0,0,0,2), -2)
lag(c(1,0,0,0,1,0,0,0,2), -2, strategy = 'zero')

Run the code above in your browser using DataLab