[Rd] should base R have a piping operator ?
John Mount
jmount @end|ng |rom w|n-vector@com
Sun Oct 6 18:58:46 CEST 2019
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 using 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.
More information about the R-devel
mailing list