-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
The cur_column() function does not detect the values, using !!!. I read that in across, some parts may be evaluated too early.
Is there a way to replace the !!! call in that case?
The code works outside across.
Brief description of the problem
library(dplyr, warn.conflicts = FALSE)
d <- tibble(x = 1:2, y = 7:8)
values <- list(x = c("1" = "yes", "2" = "no"),
y = c("7" = "YEs", "8" = "No")
)
d %>%
mutate(across(any_of(names(values)),
.fn = ~ recode(., !!!(values[[(cur_column())]])))
)
#> Error: `cur_column()` must only be used inside `across()`.
d %>% mutate(x = recode(x, !!!(values[["x"]])))
#> # A tibble: 2 x 2
#> x y
#> <chr> <int>
#> 1 yes 7
#> 2 no 8Created on 2021-05-21 by the reprex package (v2.0.0)
Metadata
Metadata
Assignees
Labels
No labels