Skip to content

Commit af481ab

Browse files
Add rename feature of dplyr select to docs (#7718)
1 parent 030f159 commit af481ab

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

man/rmd/select.Rmd

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ starwars |> select(homeworld, height, mass)
3434
iris |> select(Sepal.Length, Petal.Length)
3535
```
3636

37+
If you use a named vector to select columns, the output will have
38+
its columns renamed:
39+
40+
```{r}
41+
selection <- c(
42+
new_homeworld = "homeworld",
43+
new_height = "height",
44+
new_mass = "mass"
45+
)
46+
starwars |> select(all_of(selection))
47+
```
48+
3749
## Operators:
3850

3951
The `:` operator selects a range of consecutive variables:

man/select.Rd

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)