Passing column name as parameter to a function using dplyr
问题 I have a dataframe like below : transid<-c(1,2,3,4,5,6,7,8) accountid<-c(a,a,b,a,b,b,a,b) month<-c(1,1,1,2,2,3,3,3) amount<-c(10,20,30,40,50,60,70,80) transactions<-data.frame(transid,accountid,month,amount) I am trying to write function for total monthly amount for each accountid using dplyr package verbs. my_sum<-function(df,col1,col2,col3){ df %>% group_by_(col1,col2) %>%summarise_(total_sum = sum(col3)) } my_sum(transactions, "accountid","month","amount") To get the result like below: