sample_classes {scutr} | R Documentation |
Stratified index sample of different values in a vector.
Description
Stratified index sample of different values in a vector.
Usage
sample_classes(vec, tot_sample)
Arguments
vec |
Vector of values to sample from. |
tot_sample |
Total number of samples. |
Value
A vector of indices that can be used to select a balanced population of values from vec
.
Examples
vec <- sample(1:5, 30, replace = TRUE)
table(vec)
sample_ind <- sample_classes(vec, 15)
table(vec[sample_ind])
[Package scutr version 0.2.0 Index]