| augment_study | R Documentation |
A parameter or formula may refer to a column data already has as readily as
to a variable defined earlier in the same specification. A variable that
already exists is refused rather than overwritten.
augment_study(data, specification, seed = NULL, envir = parent.frame())
data |
A base |
specification |
A tidy definition table created with
|
seed |
Optional random seed. |
envir |
Environment used to resolve functions and external values named
by a |
A simulab_sim base data.frame with one row per row of data,
containing the original and new variables. Use
as.data.frame(x, what = "definitions") for the generating definitions.
simulab_existing_variable when the specification names a column data
already has.
# Distribution calls, generated into data that is already there.
head(augment_study(
data.frame(id = 1:100, treated = rep(0:1, each = 50)),
specification = define_variables(
outcome = normal(mean = 3 + 2 * treated, sd = 1),
visits = poisson(lambda = 4)
),
seed = 3
))
base <- simulate_study(
n = 100,
specification = define_variables(
define_variable("baseline", formula = "0", variance = "1", distribution = "normal")
),
seed = 1
)
result <- augment_study(
base,
specification = define_variables(
define_variable("outcome", formula = "2 * baseline", variance = "1",
distribution = "normal")
),
seed = 2
)
head(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.