Upcoming native pipe for R will support a lambda-alike operator '=>' when data needs to be assigned: mtcars |> subset(cyl == 4) |> d => lm(mpg ~ disp, data = d) which is quite nice and avoids the backslash lambda-alike. See @LukeTierney4 on r-devel just now. #rstats

Jan 12, 2021 Β· 8:16 PM UTC

6
36
4
162
Nicer still with ligatures (here via #emacs using @nordtheme)
1
3
34
Huh, the more I look at it, the more I like it. This will be easier to teach β€œif you want an argument other than the first, you declare it like this”, versus the magic β€œ.” Really glad they did this versus requiring lambda notation.
1
I’m finding this notation uneasy. This is how it works now, no? -> d assigns to d |> d calls the d function Putting a => *after* the d changes the meaning of the pipe operator? -> d |> myfun(a, d) makes more sense to me
As opposed to mtcars |> subset(cyl == 4) |> lm(mpg ~ disp, data = .) ?
2
Will it work outside of the pipe? In JavaScript for example we can do const myFun = x => x * 2 Which is definitely neat.
2
So the difference from splitting the statement into one with -> d at the end and putting the lm on a new line is just that then it is two lines instead of one with =>? Or is there more to this? What's the benefit of doing this? Memory? I'm curious. Thanks!
2
1