Save up to $499! Grab all Python courses for $49 or all online courses we’ve ever launched for only $169. Only Feb 11-16. Happy Valentine's!
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")