lagMultiple | R Documentation |
Compute a lagged version of the input data with multiple lags at once
lagMultiple(x, k = 1, name = NULL)
x |
A vector, single column matrix, or univariate time series. Can also be a multi-column matrix if 'k' is length 1. |
k |
(Optional) An integer vector containing a number of lags. Defaults to 1 |
name |
(Optional) A name to be used in the lagged data.frame. Defaults to the name of the variable passed to 'x'. If that is not possible, 'name' will default to "X". |
Returns a data.frame of the lagged variable. The number of rows is the same as the length of the input vector. The number of columns is the number of lags to be used. Each column retains the name of the original variable and includes the number of lags used for that column. If 'x' is a multi-column matrix, returns a matrix of the same number of columns with no names.
# Creating dummy data x <- rnorm(10) # for lags 1-5 lagMultiple(x, 1:5) # 1 lag with a matrix of dummy data lagMultiple(matrix(1:100, 10, 10), 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.