[Rd] New pipe operator

Dénes Tóth toth@dene@ @end|ng |rom kogentum@hu
Fri Dec 4 16:05:45 CET 2020


On 12/4/20 3:05 PM, Duncan Murdoch wrote:
> ...
> 
> It's tempting to suggest it should allow something like
> 
>    mtcars |> subset(cyl == 4) |> lm(mpg ~ disp, data = .)
> 
> which would be expanded to something equivalent to the other versions: 
> but that makes it quite a bit more complicated.  (Maybe _ or \. should 
> be used instead of ., since those are not legal variable names.)

I support the idea of using an underscore (_) as the placeholder symbol. 
  Syntactic sugars work the the best if 1) they require less keystrokes 
and/or 2) are easier to read compared to the "normal" syntax, and 3) can 
not lead to unexpected bugs (which is a major problem with the magrittr 
pipe). Using '_' fulfills all of these criteria since '_' can not clash 
with any variable in the environment.

Denes



More information about the R-devel mailing list