sample_classes: Stratified index sample of different values in a vector.

View source: R/undersample.R

sample_classesR 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])

scutr documentation built on Nov. 18, 2023, 1:08 a.m.