R/grouped-df.r
new_grouped_df.Rd
new_grouped_df()
is a constructor 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()
validates the attributes of a grouped_df
.
new_grouped_df(x, groups, ..., class = character()) validate_grouped_df(x)
x | A data frame |
---|---|
groups | The grouped structure, |
... | additional attributes |
class | additional class, will be prepended to canonical classes of a grouped data frame. |
# 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 x 1 #> x #> <dbl> #> 1 0.0568 #> 2 0.0843 #> 3 0.231 #> 4 0.0150 #> 5 0.0493