Resample clusters from an observed data set
bootstrap_clusters(clusters, n_boot = NULL)
clusters | data frame of observed data with the following columns
|
---|---|
n_boot | number of clusters to resample. If NULL, will re-sample as many in original cluster |
data frame with new cluster_id variable but can be traced back to original cluster
through the column original_id
data <- data.frame(cluster_id = c("a", "a", "a", "b", "b", "c", "c", "d"), x = c(1, 0, 1, 1, 1, 0, 1, 0)) boot_clusters <- bootstrap_clusters(clusters = data) boot_clusters#> cluster_id x original_id #> 1 1 1 a #> 2 1 0 a #> 3 1 1 a #> 4 2 0 c #> 5 2 1 c #> 6 3 0 d #> 7 4 0 c #> 8 4 1 c