When a parameter of a function is a string rather than a quosure (e.g. from a Shiny UI) I can think of 2 options to use it in a dplyr::mutate
call:
string -> quosure
library(dplyr) var <- "am" mtcars %>% mutate(!!rlang::sym(var) := !!rlang::sym(var) + 1)
mutate_at
library(dplyr) var <- "am" mtcars %>% mutate_at(var, funs(. + 1))
Is there any reason to prefer one of the other? Are there any border cases which I may not be aware of? For consistency I want to stick to one option and I need to decide which one I should choose. Option 2 needs less dependencies, but I want to eb sure that both variants are indeed identical.