Decision Mechanics

Insight. Applied.

  • Services
    • Decision analysis
    • Big data analysis
    • Software development
  • Articles
  • Blog
  • Privacy
  • Hire us

R now has native pipes

May 18, 2021 By editor

The latest release of R introduces an F#-style pipe operator.

Pipes have been available in R for a while, via the magrittr package. However, with the release of R 4.1.0, pipes are supported in base R.

The syntax has changed from that used in magrittr. The magrittr pipe operator is %>%. The new base R pipe operator is |>.

So, instead of

df %>% head()

we have

df |> head()

R 4.1.0 also introduces a lightweight, lambda-style function syntax, which can be usefully combined with the new pipe operator when piping to an argument other than the first one.

iris |> {\(x) lm(Sepal.Width ~ Sepal.Length, data = x)}()
Print Friendly, PDF & Email

Share this:

  • Email
  • Twitter
  • LinkedIn
  • Facebook

Filed Under: Data analysis Tagged With: magrittr, pipe, R

Search

Subscribe to blog via e-mail

Subscribe via RSS

Recent posts

  • Data Wrangler
  • The Trolley Problem
  • Counting votes using Excel
  • Accuracy vs precision
  • It’s not because we have insufficient data…

Copyright © 2025 · Decision Mechanics Limited · info@decisionmechanics.com