Use the new R pipe built into R 4.1

The R language has a new, built-in pipe operator as of R version 4.1:  |> %>% is the pipe that most R users know. Originally from the magrittr package, it’s now used in many other packages as well. (If you’re wondering where the magrittr name came from, it’s a reference to Belgian artist Rene Magritte and one of his paintings, The Treachery of Images, that says in French: “This is not a pipe.”) Here’s a somewhat trivial example using the %>% pipe with the mtcars data set and a couple of dplyr functions. This code filters the data for rows with more than 25 mpg and arranges the results by descending miles per gallon:To read this article in full, please click here

Nov 30, -0001 - 00:00
 0
Use the new R pipe built into R 4.1
Techatty All-in-1 Publishing
Techatty All-in-1 Publishing

The R language has a new, built-in pipe operator as of R version 4.1:  |> 

%>% is the pipe that most R users know. Originally from the magrittr package, it’s now used in many other packages as well. (If you’re wondering where the magrittr name came from, it’s a reference to Belgian artist Rene Magritte and one of his paintings, The Treachery of Images, that says in French: “This is not a pipe.”)

Here’s a somewhat trivial example using the %>% pipe with the mtcars data set and a couple of dplyr functions. This code filters the data for rows with more than 25 mpg and arranges the results by descending miles per gallon:

To read this article in full, please click here

Talk to Techatty
Talk to Techatty
Techatty Connecting the world of tech differently! Read. Write. Learn. Thrive. Make an informed decision without distractions. We are building tech media and publication networks to connect YOU and everyone to reliable information, opportunities, and resources to achieve greater success.