powered by
Analogous function for lead and lag in dplyr by wrapping data.table's shift.
lead
lag
shift
lead(x, n = 1L, fill = NA)lag(x, n = 1L, fill = NA)
lag(x, n = 1L, fill = NA)
A vector
a positive integer of length 1, giving the number of positions to lead or lag by. Default uses 1
Value to use for padding when the window goes beyond the input length. Default uses NA
NA
lead,shift
lead(1:5) lag(1:5) lead(1:5,2) lead(1:5,n = 2,fill = 0)
Run the code above in your browser using DataLab