Description Usage Arguments Value Examples
Stratify random values by group
1 | stratify_by_group(num_groups, groups, distribution = stats::rnorm, ...)
|
num_groups |
natural number, number of group values to create |
groups |
vector of natural numbers of at most
magnitude |
distribution |
random value function that takes at least one parameter, the number of values to return |
... |
additional parameters for |
a vector of random values of length
length(groups)
with a functional dependence on
groups
1 2 3 4 5 6 7 8 9 10 | num_groups <- 5
num_samples <- 20
groups <- generate_groups(num_samples, num_groups)
groups
v1 <- stratify_by_group(num_groups, groups)
v1
table(groups, v1)
v2 <- stratify_by_group(num_groups, groups, distribution = function(n) {base::sample.int(2, size = n, replace = TRUE)})
v2
table(groups, v2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.