Description Usage Arguments Value Author(s) Examples
Given a tibble (or data frame) and a list with variables names and disired lags, the function creates a tibble with the lagged variables.
| 1 | 
| data | A tbl with variables in columns. | 
| vars_lags | list with variables names and disired lags | 
| suffix | Character string with suffix for lagged variables. Default is "_l". | 
An object of class tibble (tbl) with lagged variables.
J. Renato Leripio
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## Not run: 
library(tidyverse)
library(tstools)
data <- tibble(Date = seq.Date(from = as.Date("2012-01-01"),
                               to = as.Date("2018-06-01"),
                               by = "month"),
               V1 = rnorm(mean = 0, sd = 1, n = 78),
               V2 = rnorm(mean = 1, sd = 2, n = 78),
               V3 = rnorm(mean = 5, sd = 1, n = 78))
data_lagged <- add_lags(data, vars_lags = list("V1" = 1:3, "V2" = 2, "V3" = c(1,7)), suffix = "_l")
              
## End(Not run)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.