Skip to content
Prev 59421 / 63430 Next

[External] brief update on the pipe operator in R-devel

'=>' can be defined as a function.  E.g., it could be the logical "implies"
function:
    > `=>` <- function(x, y) !x | y
    > TRUE => FALSE
    [1] FALSE
    > FALSE => TRUE
    [1] TRUE
It might be nice then to have deparse() display it as an infix operator
instead of the current prefix:
    > deparse(quote(p => q))
    [1] "`=>`(p, q)"
There was a user who recently wrote asking for an infix operator like -> or
=> that would deparse nicely for use in some sort of model specification.

When used with |>, the parser will turn the |> and => into an ordinary
looking function call so deparsing is irrelevant.
    > deparse(quote(x |> tmp => f(7,arg2=tmp)))
    [1] "f(7, arg2 = x)"

-Bill
On Tue, Jan 12, 2021 at 12:01 PM Dirk Eddelbuettel <edd at debian.org> wrote: