View source: R/preprocessing.R
computeWindowVars | R Documentation |
initial description
computeWindowVars(
dat,
vars = vars,
nestVars = NULL,
FUN = "mean",
window = "All",
timeVar = NULL,
burnIn = 0,
na.rm = F,
onlyNewVarsOut = F,
verbose = F,
...
)
dat |
a data.frame object |
vars |
a vector of variables names, corresponding to columns in the dat object for which the computation should be carried out |
nestVars |
either a character object or a vector of character objects with the column names in the dat object, indicating the nesting of the data (e.g., participant ID). Up to three nesting layers can be defined. |
a data frame with additional window variable(s)
dat <- data.frame(ID = rep(1:2, each = 30), period = rep(1:2, each = 15), a = runif(60, max = 10),
b = Sys.Date()+1:60, cat = sample(c("A","B"), 60, replace = T))
computeWindowVars(dat, vars = "a") # without nestVar
computeWindowVars(dat, vars = c("a"), nestVars = "ID")
computeWindowVars(dat, vars = c("a"), nestVars = c("ID","period", "cat"), burnIn = 1)
computeWindowVars(dat, vars = c("a"), nestVars = "ID", FUN = "sd")
computeWindowVars(dat, vars = c("a"), nestVars = "ID", FUN = "mean", window = 2, timeVar = "b")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.