View source: R/preprocessing.R
lagVars | R Documentation |
Creates extra column(s) with lagged variables according to the order of the data frame.
lagVars(
dat,
lags = 1,
vars = vars,
diffvars = diffvars,
unit = "auto",
verbose = F,
...
)
dat |
data.frame containing the variables to be lagged |
lags |
vector defining the |
vars |
names of the columns in the data.frame that should be lagged |
diffvars |
names of columns in the data.frame of which the difference to the current row should be taken (this is particularly helpful for dealing with time variables and time differences) |
unit |
character value, if time variables are being lagged and the difference is taken, which time unit should be used to calculate the difference |
verbose |
boolean indicating about the state of the process be displayed |
data.frame with new columns containing the lagged variables
lagVarsNested
dat <- data.frame(a = runif(10, max = 10),
b = Sys.Date()+1:10)
lagVars(dat, lags = -1:2, vars = c("a","b"),
diffvars = "b", unit = "hours")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.