Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Filtering by row
Extracting data by column
Practice using filter() and select()
The pipe operator
22. More pipes!
Sorting rows
Summary

Instruction

Did you see an advantage to using the pipe operator? Compared to the following line, it's more readable:

filter(select(data, conditions), conditions)

Soon, we will write even longer code, and we'll see more advantages to using pipes. For now, let's see how we can add more conditions to a statement.

Let's try selecting country_name and population information for countries with a population over 10,000,000. The code looks like this:

countries %>%
  select(country_name, population) %>%
  filter(population > 10 000 000)

Exercise

Select the country_name, population, and continent information for Asian countries with populations under 1,000,000.

Stuck? Here's a hint!

Type:

countries %>%
  select(country_name, population, continent) %>%
  filter(population < 1000000, continent == "Asia")