In itself the function works, but I am trying to loop through all the columns in the data, I know using ~apply() works and would love your help on using this thanks.
library(scales)
factorVars <- select_if(df, is.factor)
## function to tidy up to a summary table
tidy_eval_arrange <- function(.data, var) {
tidydata <- .data %>%
count({{var}}) %>%
mutate(pct = n / sum(n),
pctlabel = paste0(round(pct * 100), "%"))
print(tidydata)
}
## The issue is here, prints without calculating the percentage properly.
nm <- names(factorVars)
for(i in seq_along(nm)){
tidy_eval_arrange(df, nm[i])
}