sample_classes | R Documentation |
Stratified index sample of different values in a vector.
sample_classes(vec, tot_sample)
vec |
Vector of values to sample from. |
tot_sample |
Total number of samples. |
A vector of indices that can be used to select a balanced population of values from vec
.
vec <- sample(1:5, 30, replace = TRUE)
table(vec)
sample_ind <- sample_classes(vec, 15)
table(vec[sample_ind])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.