| simulate_until_event | R Documentation |
Simulate events and retain records through the nth event
simulate_until_event(
data,
definition,
occurrence = 1L,
id = "id",
period = "period",
seed = NULL,
envir = parent.frame(),
batch = NULL
)
data |
Long-form base |
definition |
One binary variable definition from |
occurrence, id, period |
Event trimming arguments. |
seed |
Optional random seed. |
envir |
Formula evaluation environment. |
batch |
Optional single positive whole number. When given, the
simulator runs |
A simulab_sim base data.frame with the generated event indicator
and records through the requested occurrence.
# Long-form input: one row per unit per period.
data <- expand_periods(data.frame(id = 1:30), periods = 8,
id = "id", period = "period")
result <- simulate_until_event(
data,
definition = define_variable("event", formula = "0.3", distribution = "binary"),
occurrence = 1,
seed = 1
)
head(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.