|
Thanks, the video helped explain some things, along with this post from the R-devel list: https://stat.ethz.ch/pipermail/r-devel/2020-December/080173.... The reason for announcing the new lambda syntax at the same time seems to be to enable certain workflows that the magrittr pipe supports. The %>% operator, by default, pipes to the first argument of a function. If you want to pipe to a different argument, you can do: a %>% func(x, arg2 = .) It seems like the native pipe doesn't support a placement argument, but you can use the new, more concise lambda operator: a |> \(d) func(x, arg2 = d) A little more verbose, but it's not a very common use case, it's more general, and I'd happily trade a little more verbosity for the rest of the improvements. (That said, I haven't played around with the magrittr 2.0 improvements yet, so maybe the difference is going to end up being less than the presentation suggests.) |
I tend to use it a lot if I'm just piping a vector to base functions (gsub/grep have x as their third argument.
This syntax looks like it makes that a little harder, but the new error messages are going to make everything so much better that I'm totally fine with it.