Just saw this on the R-devel news: R now provides a simple native pipe syntax ?|>? as well as a shorthand notation for creating functions, e.g. ?\(x) x + 1? is parsed as ?function(x) x + 1?. The pipe implementation as a syntax transformation was motivated by suggestions from Jim Hester and Lionel Henry. These features are experimental and may change prior to release. This is a good addition; by using "|>" instead of "%>%" there should be a chance to get operator precedence right. That said, the ?Syntax help topic hasn't been updated, so I'm not sure where it fits in. There are some choices that take a little getting used to: > mtcars |> head Error: The pipe operator requires a function call or an anonymous function expression as RHS (I need to say mtcars |> head() instead.) This sometimes leads to error messages that are somewhat confusing: > mtcars |> magrittr::debug_pipe |> head Error: function '::' not supported in RHS call of a pipe but mtcars |> magrittr::debug_pipe() |> head() works. Overall, I think this is a great addition, though it's going to be disruptive for a while. Duncan Murdoch
> Error: function '::' not supported in RHS call of a pipeTo me, this error looks much more friendly than magrittr's error. Some of them got too used to specify functions without (). This is OK until they use `::`, but when they need to use it, it takes hours to figure out why mtcars %>% base::head #> Error in .::base : unused argument (head) won't work but mtcars %>% head works. I think this is a too harsh lesson for ordinary R users to learn `::` is a function. I've been wanting for magrittr to drop the support for a function name without () to avoid this confusion, so I would very much welcome the new pipe operator's behavior. Thank you all the developers who implemented this! Best, Hiroaki Yutani 2020?12?4?(?) 20:51 Duncan Murdoch <murdoch.duncan at gmail.com>:> > Just saw this on the R-devel news: > > > R now provides a simple native pipe syntax ?|>? as well as a shorthand > notation for creating functions, e.g. ?\(x) x + 1? is parsed as > ?function(x) x + 1?. The pipe implementation as a syntax transformation > was motivated by suggestions from Jim Hester and Lionel Henry. These > features are experimental and may change prior to release. > > > This is a good addition; by using "|>" instead of "%>%" there should be > a chance to get operator precedence right. That said, the ?Syntax help > topic hasn't been updated, so I'm not sure where it fits in. > > There are some choices that take a little getting used to: > > > mtcars |> head > Error: The pipe operator requires a function call or an anonymous > function expression as RHS > > (I need to say mtcars |> head() instead.) This sometimes leads to error > messages that are somewhat confusing: > > > mtcars |> magrittr::debug_pipe |> head > Error: function '::' not supported in RHS call of a pipe > > but > > mtcars |> magrittr::debug_pipe() |> head() > > works. > > Overall, I think this is a great addition, though it's going to be > disruptive for a while. > > Duncan Murdoch > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
> This is a good additionI can't understand why so many people are calling this a "pipe". Pipes connect processes, via their I/O streams. Arguably, a more general interpretation would include sockets and files. https://en.wikipedia.org/wiki/Pipeline_(Unix) https://en.wikipedia.org/wiki/Named_pipe https://en.wikipedia.org/wiki/Anonymous_pipe As far as I can tell, the magrittr-like operators are functions (not pipes), with nonstandard syntax. This is not consistent with R's original design philosophy, building on C, Lisp and S, along with lots of *important* math and stats. It's possible that some parties are interested in creating a kind of "data pipeline". I'm interested in this myself, and I think we could discuss this more. But I'm not convinced the magrittr-like operators help to achieve this goal. Which, in my opinion, would require one to model programs as directed graphs, along with some degree of asynchronous input. Presumably, these operators will be added to R anyway, and (almost) no one will listen to me. So, I would like to make one suggestion: Is it possible for these operators to *not* be named: The R Pipe The S Pipe Or anything with a similar meaning. Maybe tidy pipe, or something else that links it to its proponents?