Learn R Programming

leakr (version 0.1.0)

stratified_sample: Stratified sampling helper

Description

This function performs stratified sampling based on the provided target vector. The sampling is done proportionally to the distribution of values in the target vector.

Usage

stratified_sample(target_vec, n_sample)

Value

A vector of indices representing the sampled observations.

Arguments

target_vec

A vector representing the target variable used for stratification. The function will sample from each class (level) proportionally.

n_sample

The total number of samples to draw.