Description Usage Arguments Value Examples
Given a data.frame with sample size allocation per strata and a data.frame with the sampling frame it selects random samples.
1 2 | select_sample(allocation, sampling_frame, sample_size = sample_size,
stratum = stratum)
|
allocation |
|
sampling_frame |
|
sample_size |
unquoted column with sample sizes in the allocation data.frame |
stratum |
unquoted column with strata in the allocation and
sampling_frame |
A data.frame
with the selected sample, it will have the same
columns as the original sampling frame plus a column indicating the sample
size in the stratum of each selected observation.
1 2 3 4 5 6 7 | sampling_frame <- data.frame(id = 1:100,
str = sample(1:5, 100, replace = TRUE),
val = rnorm(100))
allo <- sampling_frame %>%
group_by(str) %>%
summarise(n = 0.4 * n())
select_sample(allo, sampling_frame, n, str)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.