stratsample: Take a stratified sample

Description Usage Arguments Value See Also Examples

View source: R/stratsample.R

Description

This function takes a stratified sample without replacement from a data set.

Usage

1
stratsample(strata, counts)

Arguments

strata

Vector of stratum identifiers; will be coerced to character

counts

named vector of stratum sample sizes, with names corresponding to the values of as.character(strata)

Value

vector of indices into strata giving the sample

See Also

sample

The "sampling" package has many more sampling algorithms.

Examples

1
2
3
  data(api)
  s<-stratsample(apipop$stype, c("E"=5,"H"=4,"M"=2))
  table(apipop$stype[s])

survey documentation built on June 23, 2017, 4:41 a.m.

Search within the survey package
Search all R packages, documentation and source code