When across() is applied to 0 variable, it behaves differently depending on whether the tibble contains columns or not:
library(dplyr)
tibble(hello = 1:5) %>% mutate(across(NULL, ~ .x + 1))
# # A tibble: 5 x 1
# hello
# <int>
# 1 1
# 2 2
# 3 3
# 4 4
# 5 5
tibble(.rows = 5) %>% mutate(across(NULL, ~ .x + 1))
# Erreur : Problem with `mutate()` input `..1`.
# x Can't select within an unnamed vector.
# i Input `..1` is `across(NULL, ~.x + 1)`.
# Run `rlang::last_error()` to see where the error occurred.
This problem doesn't occur when using scoped verbs:
library(dplyr)
tibble(hello = 1:5) %>% mutate_at(NULL, ~ .x + 1)
# # A tibble: 5 x 1
# hello
# <int>
# 1 1
# 2 2
# 3 3
# 4 4
# 5 5
tibble(.rows = 5) %>% mutate_at(NULL, ~ .x + 1)
# # A tibble: 5 x 0
(Version of dplyr: 1.0.2)
When across() is applied to 0 variable, it behaves differently depending on whether the tibble contains columns or not:
This problem doesn't occur when using scoped verbs:
(Version of dplyr: 1.0.2)