group_by_all

0th

Percentile

Group by a selection of variables

These scoped variants of group_by() group a data frame by a selection of variables. Like group_by(), they have optional mutate semantics.

Usage
group_by_all(.tbl, .funs = list(), ...)

group_by_at(.tbl, .vars, .funs = list(), ..., .add = FALSE)

group_by_if(.tbl, .predicate, .funs = list(), ..., .add = FALSE)

Arguments
.tbl

A tbl object.

.funs

List of function calls generated by funs(), or a character vector of function names, or simply a function.

Bare formulas are passed to rlang::as_function() to create purrr-style lambda functions. Note that these lambda prevent hybrid evaluation from happening and it is thus more efficient to supply functions like mean() directly rather than in a lambda-formula.

...

Additional arguments for the function calls in .funs. These are evaluated only once, with tidy dots support.

.vars

A list of columns generated by vars(), a character vector of column names, a numeric vector of column positions, or NULL.

.add

Passed to the add argument of group_by().

.predicate

A predicate function to be applied to the columns or a logical vector. The variables for which .predicate is or returns TRUE are selected. This argument is passed to rlang::as_function() and thus supports quosure-style lambda functions and strings representing function names.

Aliases
  • group_by_all
  • group_by_at
  • group_by_if
Examples
# NOT RUN {
# 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():
group_by_all(mtcars, as.factor)
group_by_if(iris, is.factor, as.character)
# }
Documentation reproduced from package dplyr, version 0.7.8, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.