| simulate_clusters | R Documentation |
Simulate Gaussian clusters
simulate_clusters(
n,
centers,
sds = 1,
proportions = NULL,
labels = NULL,
seed = NULL,
batch = NULL
)
n |
Sample size. |
centers |
Matrix with one row per cluster and one column per variable,
or a tidy data frame with columns |
sds |
Scalar, per-variable vector, cluster-by-variable matrix, or a
tidy data frame with columns |
proportions |
Optional cluster proportions. |
labels |
Optional cluster labels. |
seed |
Optional random seed. |
batch |
Optional single positive whole number. When given, the
simulator runs |
A simulab_sim base data.frame with one row per observation and
columns id, cluster (the true membership label) and one column per
variable. One tidy table comes from as.data.frame():
what = "parameters" has one row per cluster-variable combination with
columns cluster, variable, center, sd and proportion.
# `centers` is one row per cluster and one column per variable.
result <- simulate_clusters(
n = 150,
centers = matrix(c(0, 0, 4, 4, 0, 4), nrow = 3, byrow = TRUE),
sds = 1,
seed = 1
)
head(result)
as.data.frame(result, what = "parameters")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.