I'm writing an R script and I need to allow user to specify the name of variable that will be proccessed by hand, i.e.
var <- 'user_name'
Generally then I refer to that using rlang::sym
and quoting/unquoting mechanism. However, I need to use tidyr::replace_na
and none of my ideas worked here as the name of the variable has to be specified inside list
.
How can I refer to my var
in such a case? I was thinking about something like below:
data <- data %>% replace_na(list(sym(var) = 0))
But it didn't work...