diff_vars | R Documentation |
n
Lags, k
DifferencesThis function takes a column and builds the differences based
on the difference k
between the column and the lag n
specified.
diff_vars(
df,
col = NULL,
lags = 1,
diff = 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. |
diff |
number - specify the number of differences for differencing. |
mutate_type |
string - select whether to |
Build the differences of a variable
A dataframe with the lagged differences of the column specified.
library(magrittr)
df <- datasets::airmiles %>% as.vector() %>% tibble::enframe(name = "airmiles")
diff_vars(df, col = "airmiles") %>% head()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.