scoped {dplyr} | R Documentation

## Operate on a selection of variables

### Description

The variants suffixed with `_if`, `_at` or `_all` apply an expression (sometimes several) to all variables within a specified subset. This subset can contain all variables (`_all` variants), a `vars()` selection (`_at` variants), or variables selected with a predicate (`_if` variants).

### 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.
`.vars` | A list of columns generated by `vars()`, or a character vector of column names, or a numeric vector of column positions.
`.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.
`...` | Additional arguments for the function calls in `.funs`. These are evaluated only once, with explicit splicing.

### Details

The verbs with scoped variants are:

- `mutate()`, `transmute()` and `summarise()`. See `summarise_all()`.

- `filter()`. See `filter_all()`.

- `group_by()`. See `group_by_all()`.

- `rename()` and `select()`. See `select_all()`.

- `arrange()`. See `arrange_all()`

There are three kinds of scoped variants. They differ in the scope of the variable selection on which operations are applied:

- Verbs suffixed with `_all()` apply an operation on all variables.

- Verbs suffixed with `_at()` apply an operation on a subset of variables specified with the quoting function `vars()`. This quoting function accepts `select_vars()` helpers like `starts_with()`. Instead of a `vars()` selection, you can also supply an integerish vector of column positions or a character vector of column names.

- Verbs suffixed with `_if()` apply an operation on the subset of variables for which a predicate function returns `TRUE`. Instead of a predicate function, you can also supply a logical vector.

[Package dplyr version 0.7.4 Index]