Skip to content

Commit 13c4524

Browse files
rename_at() handles empty selection.
closes #4324
1 parent 792ca49 commit 13c4524

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

NEWS.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# dplyr 0.8.1.9000
2+
3+
* `rename_at()` handles empty selection (#4324).
4+
15
# dplyr 0.8.0.9000
26

37
## Breaking changes

R/colwise-select.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ vars_select_syms <- function(vars, funs, tbl, strict = FALSE) {
108108
if (is_quosure(fun)) {
109109
fun <- quo_as_function(fun)
110110
}
111-
syms <- set_names(syms(vars), fun(vars))
111+
syms <- if (length(vars)) {
112+
set_names(syms(vars), fun(vars))
113+
} else {
114+
set_names(syms(vars))
115+
}
112116
} else if (!strict) {
113117
syms <- syms(vars)
114118
} else {

tests/testthat/test-colwise-select.R

+6
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,9 @@ test_that("select_if() and rename_if() handles logical (#4213)", {
182182

183183
})
184184

185+
test_that("rename_at() handles empty selection (#4324)", {
186+
expect_identical(
187+
mtcars %>% rename_at(vars(contains("fake_col")),~paste0("NewCol.",.)),
188+
mtcars
189+
)
190+
})

0 commit comments

Comments
 (0)