I would like to write a function that uses dplyr inside and I supply variable names as strings. Unfortunately dplyr-s use of NSE makes it rather complicated. From Programming with dplyr I get the following example
my_summarise <- function(df, var) {
  var <- enquo(var)
  df %>%
    group_by(!!var) %>%
    summarise(a = mean(a))
}
my_summarise(df, g1)
However, I would like to write function where instead of g1 I could provide "g1" and I am not able to wrap my head around how to do that. 
 
     
     
     
    