mlag_dfr: mlag_dfr: Lag multiple columns of a data frame

Description Usage Arguments Examples

View source: R/lag.R

Description

mlag_dfr: Lag multiple columns of a data frame

Usage

1
mlag_dfr(df, col_names, lags)

Arguments

df

The dataframe containing the time series data

col_names

A vector of column names to be used to create the lagged variables

lags

Number of lags to create for the column

Examples

1
2
3
4
5
6
x  <-  c(2,3,5,7,9,9,5,3)
z <- c(6,9,3,3,3,4,5,7)
y <- 1:8
df <- data.frame(Y = y, X = x, Z =z)
lag_dfr(df, "X", 1:3)
mlag_dfr(df, c("X","Z"), 1:3)

josephsdavid/tswgewrapped documentation built on July 31, 2020, 9:36 a.m.