I am trying to create a map function that loops through a set of group_bys with proportions. This gives me the proportions of variable negbud with 'Yes" & "No', by month and by x. This function works:
propneg <- function(x) {group_by(debt_by_month_demog, monthdate,{{x}}, negbud) %>%
count() %>%
ungroup() %>%
group_by(monthdate, {{x}})%>% mutate(ttl = sum(n), pctttl = n/ttl)}
But when I try to map it over multiple variables, it fails:
map_at(debt_by_month_demog,vars(UC:Region), propneg)
With the following error messages:
Error in group_by():
! Problem adding computed columns.
Caused by error in mutate():
! Problem while computing ..2 = <chr>.
Inlined constant ..2 must be size 48 or 1, not 68179.
Run rlang::last_error() to see where the error occurred
Any idea what could be going wrong?