| Title: | Sample Dataframes by a Group |
|---|---|
| Description: | Sample dataframes by group, in the form of a 'block bootstrap'. Entire groups are returned allowing for a single 'observation' to span multiple rows of the dataframe. |
| Authors: | Michael Lydeamore [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-3980-268X>), Cash Looi [aut] (ORCID: <https://orcid.org/0009-0002-7219-2753>), Kenyon Ng [aut] (ORCID: <https://orcid.org/0000-0002-6315-9831>), Mitchell O'Hara-Wild [aut] (ORCID: <https://orcid.org/0000-0001-6729-7695>) |
| Maintainer: | Michael Lydeamore <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-06-02 07:01:40 UTC |
| Source: | https://github.com/numbats/blockstrap |
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.
slice_block(.data, ...) ## S3 method for class 'data.frame' slice_block(.data, ...) ## S3 method for class 'grouped_df' slice_block(.data, n = 1, replace = FALSE, weight_by = NULL, ...)slice_block(.data, ...) ## S3 method for class 'data.frame' slice_block(.data, ...) ## S3 method for class 'grouped_df' slice_block(.data, n = 1, replace = FALSE, weight_by = NULL, ...)
.data |
A grouped data frame, generated using |
... |
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) |
A data frame with sampled complete groups
ToothGrowth |> dplyr::group_by(supp, dose) |> slice_block(n = 2)ToothGrowth |> dplyr::group_by(supp, dose) |> slice_block(n = 2)