Pipe operator in R

Base R 4.1 introduced a new operator, called pipe (|>) that directs the result of left hand side (LHS) to the right hand side (RHS) as the first argument of it. Functions that take one argument, function(argument), can be rewritten as follows: argument %>% function().”

As an example 1:3 |> sum() would result 6, since it is equivalent to sum(1:3).

Previous versions of R used pipe operator (%>%) from {magrittr} package and it gained popularity from {dplyr}.

Tags:

Categories:

Updated: