Can you show us some of the data in chocolate_bars.
A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need.
Or when you look at the man page you see you can omit the group_by and name the grouping column in the count() the way OP did
I had been treating count() as a shorthand for summarise(n = n()) with optional sort.
Have only just realised its advertised function includes the group_by and none of the examples include a group_by beforehand. Count observations by group — count • dplyr
This answer should be the best answer. It shows the simplest way of getting the result.
And this is the documentation of count: "count() lets you quickly count the unique values of one or more variables: df %>% count(a, b) is roughly equivalent todf %>% group_by(a, b) %>% summarise(n = n())". I wonder why the author of the question didn't even take a look on it (?)