This is a non-standard-evaluation problem I can't seem to solve. I want to make a function that inputs a column name and outputs a summary. For this function, it's important that the summarise(name,...)
can be assigned as input like so:
mtcars %>%
summarise(mpg = mean(mpg))
This works:
get <- function(col){
mtcars %>%
summarise(mean = mean({{ col }}))
}
get(mpg)
But this does not, and this is what I need.
get <- function(col){
mtcars %>%
summarise({{ col }} = mean({{ col }}))
}
Any help is greatly appreciated.