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