Description Usage Arguments Value Examples
Taken and adapted from https://www.tjmahr.com/sample-n-groups/
1 | sample_n_of(data, size, ...)
|
data |
tibble |
size |
the number subgroups you want sample |
... |
the column names the subgroup you want sample |
tibble with elements belonging the sampled subgroups
1 2 3 4 5 6 7 | library(dplyr)
mtcars %>% sample_n_of(2,cyl) %>% distinct(cyl)
mtcars %>%
mutate(rowid = 1:n()) %>%
group_by(cyl) %>%
do(sample_n_of(., 2,rowid))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.