Filtering and arranging
You'll often need to use the pipe operator (%>%
) to combine multiple dplyr verbs in a row. In this case, you'll combine a filter()
with an arrange()
to find the highest population countries in a particular year.
This exercise is part of the course
Introduction to the Tidyverse
Exercise instructions
- Use
filter()
to extract observations from just the year 1957, then usearrange()
to sort in descending order of population (pop
).
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
library(gapminder)
library(dplyr)
# Filter for the year 1957, then arrange in descending order of population