krangl / krangl / lag

lag

fun DataCol.lag(n: Int = 1, default: Any? = null): DataCol

Returns the "previous" column values. Useful for comparing values behind the current values.

Also see https://dplyr.tidyverse.org/reference/lead-lag.html

Parameters

n - positive integer, giving the number of positions to lag by (defaults to 1)