Introduction
Filtering by row
Extracting data by column
Practice using filter() and select()
The pipe operator
Sorting rows
Summary
26. Exercise 1

Instruction

Before we go on, let's have a quick summary. We're going to use everything we've learned to make one long instruction! What have we learned so far?

We've learned to select some columns from a tibble:

select(countries, continent)

We've learned to filter selected rows using a condition:

filter(countries, country_name == "France")

We've learned how to sort the results:

arrange(countries, area)

And we've learned to use the pipe operator to increase the readability of code:

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

Exercise

Filter all countries in Africa and North America.

Stuck? Here's a hint!

Type:

countries %>%
  filter(continent %in% c("Africa", "North America"))