View source: R/sample_groups.r
sample_groups | R Documentation |
tibble
This function lets you sample groups from a grouped tibble. The default
behaviour of sample()
on a grouped tibble is to sample within
each group, but sometimes you want to sample a few complete groups. This lets
you do that.
sample_groups(grouped_df, n, replace = FALSE)
grouped_df |
(grouped tibble) a grouped tibble from which you want to sample groups |
n |
(number) how many groups do you want? |
replace |
(boolean; default = FALSE) sample with replacement? |
Doesn't work with sf
s because of the geometry column.
a grouped tibble containing n
groups from the original data
dplyr::storms %>%
dplyr::group_by(name) %>%
sample_groups(2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.