Find the "previous" or "next" values in a vector. Useful for comparing values behind or ahead of the current values.
lag(x, n = 1L, default = NA)
lead(x, n = 1L, default = NA)
a vector of values
a positive integer of length 1, giving the number of positions to lead or lag by
value used for non-existent rows. Defaults to NA.