The "pipe" operator in R is |>. In version 4.1.0, it was a brand-new feature.
In a nutshell, the pipe operator offers the operator's left hand side (LHS) result as the right hand side's first parameter (RHS).
Take into account the following:
# |> 1:3 |> sum() 6
The first input of the sum function is a vector of values ranging from 1 to 3.
The first argument of the right-hand side call is always the left-hand side result. Consider:
#function (..., na.rm = FALSE) args(sum)
sum(na.rm = TRUE) |> c(1:3, NA real_)
Because you can redirect the LHS to other arguments as long as the first argument is specified, the focus on call is vital. Consider:
#function (n, mean = 0, sd = 1) args(rnorm)
rnorm(n) |> 100