Fresh out of the #RStats oven: It is now (= R-devel to become R 4.2.0) possible to use underscore (_) as a placeholder on the right-hand side (RHS) of a forward pipe, e.g. mtcars |> subset(cyl == 4) |> lm(mpg ~ disp, data = _) github.com/wch/r-source/comm…
#RStats community, really? It's been like 5 hours now and no one noticed the big news? 😛 github.com/wch/r-source/comm… Thank you @LukeTierney4 @_lionelhenry @jimhester_ (who else?) #pipypipy
14
86
26
319
Nice indeed. But then lm(mpg ~ disp, data = mtcars, subset = cyl==4) is still shorter, and quite possibly more readable. 😉 #rstats
3
1
19
...and if you want to pipe, then I would name the formula argument, avoiding to use the data argument: mtcars |> subset(cyl == 4) |> lm(formula = mpg ~ disp)
2
1
13
Which has the added advantage of already working today with the released version of #RStats 😀

Mar 8, 2022 · 9:39 PM UTC

1
1
5
Indeed, that has worked since the introduction of the base pipe. Nevertheless, it's a nifty addition to have the underscore shortcut. Sometimes this can be quite nice and compact.
4