Save up to $499! Grab all Python courses for $49 or all online courses we’ve ever launched for only $169. Only Feb 11-16. Happy Valentine's!
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) %>%