| panel_lag | R Documentation |
Given a wide panel with a Date column followed by symbol columns, returns
the same shape with each symbol column lagged by k periods. The Date
column is preserved; leading values introduced by the lag are NA_real_.
panel_lag(df, k = 1L)
df |
data.frame or data.table with columns |
k |
Integer lag (>= 1). |
A data.table with the same columns as df, lagged by k.
x <- data.frame(Date = as.Date("2020-01-01") + 0:2, A = 1:3, B = 11:13)
panel_lag(x, 1L)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.