R - iteratively apply a function of a list of variables
My goal is to create a function that, when looped over multiple variables of a data frame, will return a new data frame containing the percents and 95% confidence intervals for each level of each variable. As an example, if I applied this function to "cyl" and "am" from the mtcars data frame, I would want this as the final result: variable level ci.95 1 cyl 4 34.38 (19.50, 53.11) 2 cyl 6 21.88 (10.35, 40.45) 3 cyl 8 43.75 (27.10, 61.94) 4 am 0 59.38 (40.94, 75.5) 5 am 1 40.62 (24.50, 59.06) So, far I have function that seems to work for a single variable; however, I have two issues that I'm