Suppose I have the following data:
test_df <- data.frame(a=rnorm(100), b=rnorm(100))
The following works:
test_df %>%
summarise(y = mean(a))
Now suppose that instead of a
i want to pass a character string
string_outcome <- "a" # I want to use this
test_df %>%
summarise(y = mean(string_outcome))
That won't work. I tried using !!string_outcome
but that does not work either. How can I fix this?