0

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?

  • 1
    It looks like you're fairly new to SO; welcome to the community! If you want great answers quickly, it's best to make your question reproducible. This includes sample data like the output from `dput(head(dataObject)))` and any libraries you are using. Check it out: [making R reproducible questions](https://stackoverflow.com/q/5963269). – Kat Feb 17 '22 at 15:54

0 Answers0