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


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")


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

Stuck? Here's a hint!


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