Learn R Programming

prnsamplr (version 0.3.0)

srs: Stratified simple random sampling

Description

Stratified simple random sampling (SRS) using permanent random numbers. Can also be used for non-stratified SRS using a dummy stratum taking the same value for each object.

Usage

srs(df, stratid, nsamp, prn)

Value

Copy of the input data frame together with the boolean variable sampled.

Arguments

df

Data frame containing the elements to sample from.

stratid

Variable in df containing the strata.

nsamp

Variable in df containing the sample sizes.

prn

Variable in df containing the permanent random numbers.

See Also

prnsamplr, samp, pps, transformprn, ExampleData.

Examples

Run this code
dfOut <- srs(df=ExampleData, 
             nsamp="nsample", 
             stratid="stratum", 
             prn="rands")

Run the code above in your browser using DataLab