I need to create a function that could group_by and summarise a data frame using the names of its columns. I'm working with dplyr version 0.4.1 (and I cannot update), so it looks like the solutions I've found on the other topics doesn't work...
Here is my example :
data <- data.frame(section=rep(c("A","B"),3), quantity=c(6:11))
#I need to get this result :
RESULT = data %>% group_by(section) %>% summarise(total=sum(quantity))
I implemented this function, but I got an error :
# function :
synthetize = function(x,column,measure){
result = x %>% group_by(column) %>% summarise(total=sum(measure))
}
RESULT2=synthetize(data,column="section",measure="quantity")
RESULT2
I tried eval
, get
, but it looks like this doesn't help