When I first started programming in R I would often use dplyr count().
library(tidyverse)
mtcars %>% count(cyl)
Once I started using apply
functions I started running into issues with count(). If I simply added ungroup() to the end of my count()'s the problems would go away.
I don't have any particular reproducibles to show. But can somebody explain what the issue likely was, why ungroup() always fixed it, and are there any drawbacks to consistently using ungroup() after every count(), or after any group_by()? Of course I'm assuming I no longer need the data grouped after it's counted or summarized.
mtcars %>% count(cyl) %>% ungroup()