Introduction
Filtering by row
Extracting data by column
Practice using filter() and select()
The pipe operator
21. Use the pipe operator
Sorting rows
Summary

Instruction

Hang on! We keep saying how simple dplyr makes R, but this is more work! Why would we bother with the pipe operator?

Pipe operators are important when the functions we perform become more complicated. Suppose we wanted to filter rows of data from certain columns. We can pass the data from the selected columns to the filter() function like this:

countries %>%
  select(country_name, continent) %>%
  filter(continent == "Africa")

Exercise

Using %>%, select the country_name and continent columns and filter rows with countries in North America.

Stuck? Here's a hint!

Type:

countries %>% 
  select(country_name, continent) %>%
  filter(continent == "North America")