What does the "pipe" %>% do?

Some example code on this page uses “%>%” but I don’t really understand what that does.

The code:

linelist %>%
  filter(
    age < 5,
    outcome == "Death"
  )

I understand that this is taking the linelist dataset and filtering for records with age greater than 5 and outcome equal to death…but why isn’t linelist an argument to the filter function?

You’re right that “%>%” is called a pipe in R.The short version of what a pipe does is pass the object to the left of pipe to the function on the right. So, the linelist object is used as the first argument of the filter function.

There are a many, many functions that work well with the pipe, and using pipes often makes code more readable. For more details, see the Epi R Handbook chapter on pipes.