Learn R Programming

multiplyr (version 0.1.1)

lag: Offset x backwards by n

Description

Offset x backwards by n

Usage

lag(x, n = 1, default = NA)

Arguments

x
Vector
n
Amount of offset by
default
Value to pad missing data with

Value

Offset values

See Also

Other utility functions: between, cumall, cumany, cummean, distribute, first, last, lead, n_distinct, n_groups, nth, n

Examples

Run this code
lag (1:10)
lag (1:10, 2)

Run the code above in your browser using DataLab