The magrittr pipe operator seems to have a problem with the R command 'return'.
foo <- function(x) {
if (x > 1) {1 %>% return()}
999
}
foo(2)
# 999
foo1 <- function(x) {
if (x > 1) {return(1)}
999
}
foo1(2)
# 1
Are there other R functions that are incompatible with magrittr's pipe operator? What is special about 'return' that makes it incompatible?
The new |> operator is explicitly incompatible with return().
foo2 <- function(x) {
if (x > 1) {1 |> return()}
999
}
foo2(2)
# Error: function 'return' not supported in RHS call of a pipe