View source: R/trans_sample_groups.R
| sample_groups | R Documentation |
Sample entire groups defined by a categorical attribute. In sampling theory, this design is known as cluster sampling (also called one-stage cluster sampling or sampling by groups). The groups are assumed to be pre-defined in the data; this function does not infer groups with clustering algorithms such as k-means.
sample_groups(attribute, n_groups)
attribute |
group-defining attribute name |
n_groups |
number of groups to sample |
returns an object of class sample_groups
data(iris)
sc <- sample_groups("Species", n_groups = 2)
iris_sc <- transform(sc, iris)
table(iris_sc$Species)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.