Description Usage Arguments See Also Examples
These scoped variants of group_by()
group a data frame by a
selection of variables. Like group_by()
, they have optional
mutate semantics.
1 2 3 4 5 | group_by_all(.tbl, .funs = list(), ...)
group_by_at(.tbl, .vars, .funs = list(), ..., .add = FALSE)
group_by_if(.tbl, .predicate, .funs = list(), ..., .add = FALSE)
|
.tbl |
A |
.funs |
List of function calls generated by Bare formulas are passed to |
... |
Additional arguments for the function calls in
|
.vars |
A list of columns generated by |
.add |
Passed to the |
.predicate |
A predicate function to be applied to the columns
or a logical vector. The variables for which |
Other grouping functions: group_by
,
group_indices
, group_rows
,
group_size
, groups
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # Group a data frame by all variables:
group_by_all(mtcars)
# Group by variables selected with a predicate:
group_by_if(iris, is.factor)
# Group by variables selected by name:
group_by_at(mtcars, vars(vs, am))
# Like group_by(), the scoped variants have optional mutate
# semantics. This provide a shortcut for group_by() + mutate():
d <- tibble(x=c(1,1,2,2), y=c(1,2,1,2))
group_by_all(d, as.factor)
group_by_if(iris, is.factor, as.character)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.