View source: R/design_structure.R
| expand_clusters | R Documentation |
Repeats every cluster-level row once per unit it contains, so cluster attributes are copied down to the units, and numbers the units.
expand_clusters(data, cluster, size, unit = "id", include_cluster_data = TRUE)
data |
Cluster-level base |
cluster |
Name of the cluster identifier. A single string naming a
column of |
size |
Units per cluster: the name of a cluster-size column of |
unit |
Name of the new unit identifier, numbered |
include_cluster_data |
Copy every cluster-level column down to the
units. A single flag, defaulting to |
A simulab_sim base data.frame with one row per unit, the unit
identifier first and then the retained cluster-level columns. The component
clusters, reached with as.data.frame(x, what = "clusters"), holds one
row per input cluster with columns cluster, the identifier values under
that fixed name whatever cluster was called, and the integer size.
clusters <- data.frame(cluster = 1:5, site = rep(c("north", "south"), length.out = 5))
result <- expand_clusters(clusters, cluster = "cluster", size = 4)
head(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.