Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
I error I got from this code is because some categories has no observations. This solution is not valid anyway because you are trying to group by and you have different numeric variables