My question is similar to these enter link description here and enter link description here, but my problem is more complex as it requires multiple dplyr operations and lazy evaluation.
This is my function:
stats <- function(col_names){
require("dplyr")
data %>%
group_by_(col_names) %>%
summarise(Count = n()) %>%
mutate(Percent = prop.table(Count)) -> temp
write.csv(temp, file=paste(col_names,".csv",sep="_"))}
Than, I want to pass every column name as an argument with do.call.
colnames <- names(data)
do.call(stats, as.list(col_names))
But I get a common error:
Error in (function (col_names) :
unused arguments ("loans_approved_amount_limit_in_account", "loans_approved_amount_limit_in_ron")
The function works if I enter the column names seperately. But I have to over 1000 columns, and so I need to automate the process.