StRS: Performs Stratified Random Sampling

View source: R/SOptim_UnsupervisedClassification.R

StRSR Documentation

Performs Stratified Random Sampling

Description

An auxiliar function to perform stratified random sampling of a set of integers.

Usage

StRS(x, strata, nsps)

Arguments

x

Vector of integer indices

strata

A vector containing the stratum number/code for each element of x (unique elements in strata must equal the names property of nsps).

nsps

An object of class table indicating the number of samples per stratum (check numSampPerStrata).

Value

A vector of indices with the selected elements of x.

See Also

sample

Examples


st <- sample(1:5,1000,replace=TRUE)
tb <- table(st)/length(st)
ind <- 1:1000

nsps <- numSampPerStrata(propStrata=tb, n=100, minSamp = TRUE, minSizeSet = 10)

StRS(x = ind, strata = st, nsps = nsps)


joaofgoncalves/SegOptim documentation built on Feb. 5, 2024, 11:10 p.m.