New Plumbing: Adding a pipe operator to Base R

I think this is the first Ihaka lecture I have attended, and Thursday 4 August was a great way to start. Online with over 30 people, and I reckon from the livestream that there were another 30 in person at the University of Auckland. All to hear Professor Luke Tierney of the University of Iowa speak on pipe operators in base R.

Who would have thought that such a topic could be so engrossing? Luke spoke about the famous pipe operator in the magrittr package, the proceeded to explain the issues that the base R developers had in deciding what features of piping were important enough to make it work in base R too.

One of the main issues to address was the way that pipes implicitly pass the output as the first argument of the new input. This is a problem for a function as fundamental as even lm(), because the data argument (generally the one you want to pass), is the second argument after the formula. Luke described several of the options that the developers canvassed before they settled on the one for release in 2022.

So for now, next time you are in R4.2.0, rty this: mtcars |> lm(mpg ~ disp, data = _)

Leave a comment