Introduction
Filtering by row
Extracting data by column
Practice using filter() and select()
The pipe operator
Sorting rows
24. Sort using pipes
Summary

Instruction

Let's try that with a more complex example. We can pass a dataset to arrange() using the pipe operator.

If we simply wanted to sort countries by population, we'd use:

countries %>%
  arrange(population)

We can add more operations, too. Suppose we only want the data from European countries. We'd use the filter() command, like so:

countries %>%
  filter(continent == "Europe") %>%
  arrange(population)

Exercise

Select countries from Africa, and sort the result by area.

Stuck? Here's a hint!

Type:

countries %>%
  filter(continent == "Africa") %>%
  arrange(area)