View source: R/preprocessing.R
insertAloneTime | R Documentation |
function to add rows for new types of observations (e.g., Alone).
insertAloneTime(
dat,
nestVars = NULL,
timeVar = "date",
catVar = "alter",
insertNA = NULL,
timeLag = 1
)
dat |
data.frame containing the relevant variables |
nestVars |
name(s) of the columns indicating how the data is nested
(e.g., ID variable). Currently up to two |
timeVar |
column name indicating the time variable |
catVar |
column name indicating the category variable |
insertNA |
A vector with the variable names that should be filled with NAs for the "not-alone" state |
timeLag |
A positive number or vector with positive numbers indicating the time in the "not-alone" state. If a vector is provided random samples of the vector will be taken. |
data.frame with addtional rows
dat <- data.frame(ID = c(rep(1,10), rep(2,10)),
day = rep(c(rep(1,5), rep(2,5)),2),
a = runif(20, max = 10),
time = Sys.time()+1:20,
cat = sample(c("X","Y","Z"), 20, replace = T))
insertAloneTime(dat, nestVars = c("ID"), timeVar = "time", catVar = "cat")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.