| simulate_density | R Documentation |
Simulate from an empirical kernel density
simulate_density(
n,
values,
variable = "value",
use_limits = FALSE,
keep_missing = FALSE,
id = "id",
seed = NULL,
batch = NULL
)
n |
Number of observations. |
values |
Numeric source values, of which at least two must be present and distinct. Missing values are dropped before the density is estimated. |
variable |
Output variable name. |
use_limits |
Constrain draws to the observed range. |
keep_missing |
Draw missing values at the source's missing-data rate, so the proportion is reproduced in expectation rather than exactly. |
id |
Identifier variable name. |
seed |
Optional random seed. |
batch |
Optional single positive whole number. When given, the
simulator runs |
A simulab_sim base data.frame with n rows and columns id and
variable, one generated density value per row.
as.data.frame(x, what = "source") gives a one-row summary of the source
values.
values <- stats::rnorm(200, mean = 5, sd = 2)
result <- simulate_density(n = 100, values = values, variable = "score", seed = 1)
head(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.