sampling: Sampling functions

Description Usage Arguments Details Examples

Description

These functions are intended to be used with sim_sample and not interactively. They are wrappers around sample_frac and sample_n.

Usage

1
2
3
4
5
6
7
8
9
sample_fraction(size, replace = FALSE, weight = NULL, groupVars = NULL)

sample_number(size, replace = FALSE, weight = NULL, groupVars = NULL)

sample_numbers(size, replace = FALSE, groupVars = NULL)

sample_cluster_number(size, replace = FALSE, weight = NULL, groupVars)

sample_cluster_fraction(size, replace = FALSE, weight = NULL, groupVars)

Arguments

size

For sample_n(), the number of rows to select. For sample_frac(), the fraction of rows to select. If tbl is grouped, size applies to each group.

replace

Sample with or without replacement?

weight

Sampling weights. This must evaluate to a vector of non-negative numbers the same length as the input. Weights are automatically standardised to sum to 1.

This argument is automatically quoted and later evaluated in the context of the data frame. It supports unquoting. See vignette("programming") for an introduction to these concepts.

groupVars

character with names of variables to be used for grouping.

Details

sample_numbers is a vectorized version of sample_number.

sample_cluster_number and sample_cluster_fraction will sample clusters (all units in a cluster).

Examples

1
2
3
4

wahani/saeSim documentation built on May 27, 2017, 11:55 p.m.