powered by
Find the "previous" or "next" values in a vector. Useful for comparing values behind or ahead of the current values.
lags.(x, n = 1L, default = NA)leads.(x, n = 1L, default = NA)
leads.(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.
# NOT RUN { x <- 1:5 leads.(x, 1) lags.(x, 1) # Also works inside of `mutate.()` test_df <- tidytable(x = 1:5) test_df %>% mutate.(lag_x = lags.(x)) # }
Run the code above in your browser using DataLab