lag_vars | R Documentation |
n
lagsThis function builds lags of a variable up to the n
lag.
lag_vars(df, col = NULL, lags = 1, mutate_type = c("mutate", "trans"))
df |
dataframe or tibble |
col |
string - specify the column/field/variable for differencing. |
lags |
number - specify the number of lags for differencing. |
mutate_type |
string - select whether to |
Build the lags of a variable.
A dataframe with the lags of the column specified.
library(magrittr)
df <- datasets::airmiles %>% as.vector() %>% tibble::enframe(name = "airmiles")
lag_vars(df, col = "airmiles") %>% head()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.