From jmount @end|ng |rom w|n-vector@com  Sun Oct  6 18:58:46 2019
From: jmount @end|ng |rom w|n-vector@com (John Mount)
Date: Sun, 6 Oct 2019 09:58:46 -0700
Subject: [Rd] should base R have a piping operator ?
In-Reply-To: <CAD4oTHHgSUr5TfLaTHxAM94E-Sqw9bW6gON7KdW324VEr524Lw@mail.gmail.com>
References: <CAEKh8uidcEWA4tzmkpQxpF=q7r93qjf-HtiWLfbT91TFGOSzFQ@mail.gmail.com>
 <CAGpovd2jxxWBUxPhMAR6ZPw1+UQzK7BzJVtps10cMBSp=EUdHQ@mail.gmail.com>
 <CALEXWq0ZvGeTbeq-AeYTSTcTwR-TR+gGczqQhWupzB2h0wa+zg@mail.gmail.com>
 <CAGpovd29V3rXSyB_SMBnbKfb3dzAFPF66ck9iU6XPB_+bS+8WQ@mail.gmail.com>
 <CAEKh8ugr0FNryRVmM64pBPxjP=4xLrC0T2OsUD27mSASAyHpVQ@mail.gmail.com>
 <CAD4oTHHgSUr5TfLaTHxAM94E-Sqw9bW6gON7KdW324VEr524Lw@mail.gmail.com>
Message-ID: <427982A4-477B-4A80-BE46-06A9FAFB32E2@win-vector.com>

Except for the isolation of local() R pretty much already has the parsing transformation you mention.


as.list(parse(text="

iris ->.; 
  group_by(., Species) ->.; 
  summarize(., mean_sl = mean(Sepal.Length)) ->.;
  filter(., mean_sl > 5)

"))

#> [[1]]
#> . <- iris
#> 
#> [[2]]
#> . <- group_by(., Species)
#> 
#> [[3]]
#> . <- summarize(., mean_sl = mean(Sepal.Length))
#> 
#> [[4]]
#> filter(., mean_sl > 5)


<sup>Created on 2019-10-06 by the [reprex package](https://reprex.tidyverse.org) (v0.3.0)</sup>

> On Oct 5, 2019, at 4:50 PM, Gabriel Becker <gabembecker at gmail.com> wrote:
> 
> 
> iris %>% group_by(Species) %>% summarize(mean_sl = mean(Sepal.Length)) %>%
> filter(mean_sl > 5)
> 
> 
> were *parsed* as, for example, into
> 
> local({
>            . = group_by(iris, Species)
> 
>            ._tmp2 = summarize(., mean_sl = mean(Sepal.Length))
> 
>            filter(., mean_sl > 5)
>       })
> 
> 
> 
> 
> Then debuggiing (once you knew that) would be much easier but behavaior
> would be the same as it is now. There could even be some sort of
> step-through-pipe debugger at that point added as well for additional
> convenience.
> 
> There is some minor precedent for that type of transformative parsing:
> 
>> expr = parse(text = "5 -> x")
> 
>> expr
> 
> expression(5 -> x)
> 
>> expr[[1]]
> 
> x <- 5
> 
> 
> Though thats a much more minor transformation.



[Rd] should base R have a piping operator ?
John Mount