group_modify does not behave as expected when the function is psych::alpha()

I'm trying to run psych::alpha on a dataset grouped by country. group_map works but as expected the list doesn't say countries, it indexes the countries ([[1]] etc) .
The reference site doesn't imply there needs to be any argument additions between group_map and group_modify
Passing through group_modify gives me the error:

Number of categories should be increased  in order to count frequencies. 
Error: The result of .f should be a data frame.
Backtrace:
 1. `%>%`(...)
 3. dplyr:::group_modify.grouped_df(., ~psych::alpha(.x, check.keys = TRUE))
 5. dplyr:::group_map.data.frame(.data, fun, .keep = .keep)
 6. dplyr:::map2(chunks, group_keys, .f, ...)
 7. base::mapply(.f, .x, .y, MoreArgs = list(...), SIMPLIFY = FALSE)
> 

This happens in my dataset where I

df%>% select(groupVar, vars1:var4)%>%group_by(groupVar)%>%group_modify(~ psych::alpha(.x, check.keys = TRUE))

and with example code

iris %>% group_by(Species) %>% 
  group_modify(~ psych::alpha(.x, check.keys = TRUE))

PS to mods: group_map is missing from packages tag

Adding link to associated GitHub issue

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.