On January 21th at 14:15 UTC , progression through exercises will be unavailable for 10 minutes due to a planned maintenance break.
Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Create new variables
Grouping and statistical functions
9. group_by() and count()
Joining datasets


Grouping data has no visible effect for us, but it is remembered by R. In a moment, you will see why this feature is so powerful.

Let's go back to our problem. Suppose we wanted to see how many countries are urban countries, per our earlier definition. We can do this using group_by() and count():

countries_urban %>%
  group_by(urban_country) %>%


Find out how many countries there are in each continent. Use group_by() and count() and data from countries_urban.

Stuck? Here's a hint!


countries_urban %>% 
  group_by(continent) %>%