1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
tidyselect implements a DSL for selecting variables. It provides helpers
for selecting variables:
- `var1:var10`: variables lying between `var1` on the left and `var10` on the right.
* [`starts_with("a")`][tidyselect::starts_with]: names that start with `"a"`.
* [`ends_with("z")`][tidyselect::ends_with]: names that end with `"z"`.
* [`contains("b")`][tidyselect::contains]: names that contain `"b"`.
* [`matches("x.y")`][tidyselect::matches]: names that match regular expression `x.y`.
* [`num_range(x, 1:4)`][tidyselect::num_range]: names following the pattern, `x1`, `x2`, ..., `x4`.
* [`all_of(vars)`][tidyselect::all_of]/[`any_of(vars)`][tidyselect::any_of()]:
matches names stored in the character vector `vars`. `all_of(vars)` will
error if the variables aren't present; `any_of(var)` will match just the
variables that exist.
* [`everything()`][tidyselect::everything]: all variables.
* [`last_col()`][tidyselect::last_col]: furthest column on the right.
* [`where(is.numeric)`][tidyselect::where]: all variables where
`is.numeric()` returns `TRUE`.
As well as operators for combining those selections:
- `!selection`: only variables that don't match `selection`.
- `selection1 & selection2`: only variables included in both `selection1` and `selection2`.
- `selection1 | selection2`: all variables that match either `selection1` or `selection2`.
When writing code inside packages you can substitute `"var"` for `var` to avoid `R CMD check` notes.
|