Edited in response to @akrun's insight:
This works:
require("magrittr")
requireNamespace("dplyr")
df <- data.frame(a = 1:5)
b_column <- c_column <- "a"
df %>% dplyr::mutate(
b = !!dplyr::sym(b_column),
c = !!dplyr::sym(c_column))
But when any one of the *_columns is NULL it doesn't:
c_column <- NULL
df %>% dplyr::mutate(
b = !!dplyr::sym(b_column),
c = !!dplyr::sym(c_column))
The resulting error is:
Error: Only strings can be converted to symbols
Run `rlang::last_error()` to see where the error occurred.
How would I make the call to ANY of the ensymboled *_column variables resilient to it being NULL?