strata.sample: Stratified sample

View source: R/strata.sample.R

strata.sampleR Documentation

Stratified sample

Description

With this function you receive a sample of each strata within your data with specified size for each strata.

Usage

strata.sample(data, n, replace = FALSE)

Arguments

data

Population data consisting of a number of columns of data and a last column specifying the strata each instance belongs to.

n

Numeric array of sample sizes for each strata to be taken.

replace

Whether the sample to be taken can have repeated instances or not.

Details

n length must be equal to number of strata in data.
On return list each strata sample can be accessed calling object$strataname where strataname are values of the last column of the original data.

Value

A list containing one strata sample per index.

Examples

data<-cbind(rnorm(500, 50, 20), rep(c("clase 1", "clase 2","clase 3","clase4"),125))
strata.sample(data=data, n=c(10,20,30,40))

samplingR documentation built on July 9, 2023, 7:26 p.m.