samp: Stratified permanent random number sampling

View source: R/samp.R

sampR Documentation

Stratified permanent random number sampling

Description

Wrapper for stratified simple random sampling (SRS) and probability-proportional-to-size (PPS) sampling using permanent random numbers. Can also be used for non-stratified sampling using a dummy stratum taking the same value for each object.

Usage

samp(method, frame, ...)

Arguments

method

pps or srs.

frame

Data frame (or data.table or tibble) containing the elements to sample from.

...

Further method-specific arguments.

Value

A copy of the input data frame together with the boolean variable sampled, as well as the numeric variables lambda and Q when pps is used.

See Also

prnsamplr, srs, pps, transformprn, ExampleData

Examples

dfOut <- samp(
  method = pps,
  frame = ExampleData,
  nsamp = ~nsample,
  stratid = ~stratum,
  prn = ~rands,
  size = ~sizeM
)

dfOut <- samp(
  method = srs,
  frame = ExampleData,
  nsamp = ~nsample,
  stratid = ~stratum,
  prn = ~rands
)

prnsamplr documentation built on April 3, 2025, 7:35 p.m.