With the magrittr pipe, one could use backticks ( ` ) to include special functions1 in the pipe chain.
For example:
library(magrittr)
c(7, 6, 5) %>% sort() %>% `[`(1)
#> [1] 5
# and
3 %>% `-`(4)
#> [1] -1
are the same as
v <- c(7, 6, 5)
v <- sort(v)
v[1]
#> [1] 5
# and
3 - 4
#> [1] -1
However, the native R pipe |> does not (yet?) allow to do that. For example:
c(7, 6, 5) |> sort() |> `[`(1)
#> Error: function '[' not supported in RHS call of a pipe
# and
3 |> `-`(4)
#> Error: function '-' not supported in RHS call of a pipe
Is there a reason why this has not been technically implemented (in case, what is the reason and are there plans to change this?) and are there any workarounds that are not too tortuous?
1 I don't know how to correctly refer to those functions (behind operators such as + or []) that need backticks to be called in their standard function form. Please edit where I say "special functions" if a more appropriate expression exists.