lag_col: lag_col

View source: R/lag_col.R

lag_colR Documentation

lag_col

Description

Given a matrix, xts, data frame, or data table, lag the values of a specified column.

Usage

lag_col(x, col_num, k = 1)

Arguments

x

matrix, xts, data frame or data table

col_num

integer, the column number to lag

k

integer, lag length, Default: 1

Value

Object of the same format with values in one column lagged.

Examples

## Not run: 
if(interactive()){
 library(magrittr)
 quantmod::getSymbols('SPY;DIA')
 x <- lapply(c('SPY','DIA'), function(x) get(x)[,4]) %>% do.call(what=cbind)
 x[1:5] %>% lag_col(1, 3)
 }

## End(Not run)

causality-loop/clhelpers documentation built on Aug. 31, 2022, 3:39 a.m.