utils_samples | R Documentation |
sample_random()
performs Simple Random Sampling or Stratified Random
Sampling
sample_systematic()
performs systematic sampling. In this case, a regular
interval of size k (k = floor(N/n)
) is generated considering the population
size (N) and desired sample size (n). Then, the starting member (r
) is
randomly chosen between 1-k
. The second element is r
+ k
, and so on.
sample_random(data, n, prop, by = NULL, weight = NULL) sample_systematic(data, n, r = NULL, by = NULL)
data |
A data frame. If |
n, prop |
Provide either |
by |
A categorical variable to compute the sample by. It is a
shortcut to |
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. |
r |
The starting element. By default, |
An object of the same type as data
.
library(metan) sample_random(data_ge, n = 5) sample_random(data_ge, n = 3, by = ENV) sample_systematic(data_g, n = 6)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.