Implementing magrittr

magrittr is the pipe, commonly used in tidyverse packages, that enables simple sequencing of operators. The simple forward pipe replaces f(x, y) with x %>% f(y). Code becomes much more readable when chaining multiple pipes together.
It’s very simple to use this in any package. the usethis package provides a command usethis::use_pipe() which takes care of everything for you. Once run, the magrittr pipe operator will be exported and available for users.

1add_number <- function(x, y) {
2  return(x + y)
3}
4
53 %>% 
6  add_number(5) %>% 
7  add_number(2)
8## result = 10