
Low-level construction and validation for the grouped_df and rowwise_df classes
Source:R/grouped-df.R, R/rowwise.R
new_grouped_df.Rdnew_grouped_df() and new_rowwise_df() are constructors designed to be high-performance so only
check types, not values. This means it is the caller's responsibility
to create valid values, and hence this is for expert use only.
validate_grouped_df() and validate_rowwise_df() validate the attributes
of a grouped_df or a rowwise_df.
Arguments
- x
A data frame
- groups
The grouped structure,
groupsshould be a data frame. Its last column should be called.rowsand be a list of 1 based integer vectors that all are between 1 and the number of rows of.data.- ...
additional attributes
- class
additional class, will be prepended to canonical classes.
- check_bounds
whether to check all indices for out of bounds problems in
grouped_dfobjects
Examples
# 5 bootstrap samples
tbl <- new_grouped_df(
tibble(x = rnorm(10)),
groups = tibble(".rows" := replicate(5, sample(1:10, replace = TRUE), simplify = FALSE))
)
# mean of each bootstrap sample
summarise(tbl, x = mean(x))
#> # A tibble: 5 × 1
#> x
#> <dbl>
#> 1 0.301
#> 2 0.151
#> 3 0.162
#> 4 -0.0733
#> 5 0.241