slice_block: Sample complete groups from a data frame
Description
Samples complete groups from a grouped data frame, including
all of each group as part of the sample. Can be considered a form of
grouped bootstrap sampling.
Usage
slice_block(.data, ...)
# S3 method for data.frame
slice_block(.data, ...)
# S3 method for grouped_df
slice_block(.data, n = 1, replace = FALSE, weight_by = NULL, ...)
Value
A data frame with sampled complete groups
Arguments
.data
A grouped data frame, generated using [dplyr::group_by](dplyr::group_by)
...
Additional arguments passed to methods
n
Number of samples to draw
replace
Should sampling be done with replacement?
weight_by
Optional expression to weight groups by (unquoted name)