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

Instruction

Maybe now you're wondering what the advantage is of using filter() and select() over standard R functions and operators? After all, combining the two can result in complicated statements.

Well, there's still more to learn, starting with the real power of tidyverse: the pipe operator. The pipe operator looks like this: %>%. It takes data on the left-hand side and uses it as an argument to the function on the right-hand side of the operator.

Let's say we wanted to select the country_name column from countries. We could write:

select(countries, country_name)

Or we could write:

countries %>%
  select(country_name)

The pipe operator will take its left hand-side (countries) and pass it as the first argument to its right hand-side function (select()). Either syntax will give us the same result. Why this is useful will soon be seen.

Exercise

Using %>%, select the continent column from countries.

Stuck? Here's a hint!

Type:

countries %>%
  select(continent)