Maybe now you're wondering what the advantage is of using
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:
Or we could write:
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.