0

I'm self-teaching R over here, and have a problem in DataCamp that I don't understand the solution to. When you run count(), I understand that it counts the frequency of each category, but does it automatically create a new column, n, as well?

    size_distribution <- restaurant_groups %>%
    count(group_size) %>%
    mutate(probability = n / sum(n))

    size_distribution
AndrewGB
  • 16,126
  • 5
  • 18
  • 49
  • 1
    Yes it does! You can try it out and see! Run the line `restaurant_groups %>% count(group_size)` to see the result of `count()`. – Gregor Thomas Jan 03 '22 at 16:07
  • 1
    Some of the best advice you can get as a new learner is "just try it". If you don't use a `<-` assignment operator, R will print the result without saving the change to any of your objects, so there no risk of messing things up by trying out commands. – Gregor Thomas Jan 03 '22 at 16:37

0 Answers0