lag_col | R Documentation |
Given a matrix, xts, data frame, or data table, lag the values of a specified column.
lag_col(x, col_num, k = 1)
x |
matrix, xts, data frame or data table |
col_num |
integer, the column number to lag |
k |
integer, lag length, Default: 1 |
Object of the same format with values in one column lagged.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.