Hi,
I'm trying to pass a string as a variable name to `select()`. It works fine with `select_()`, however, now it is deprecated.
I'm not sure how to do it with the new way `select` is suppose to work.
df <- tibble(a = 1:5, b = 6:10)
var1 <- "a"
either of this works fine:
df %>% select(a)
df %>% select_(var1)
and this doesn't work:
df %>% select(var1) # I knew this already would not work
# Error: var1: must resolve to integer column positions, not string
df %>% select(!!var1)
# Error: "a": must resolve to integer column positions, not string
df %>% select(UQ(var1))
# Error: "a": must resolve to integer column positions, not string
Honestly, I'm still struggling a little in wrapping my head around standard and non standard evaluation.
What is the proper approach to solve this issue?
Thanks in advance!
Massimo