[Rd] [External] Re: New pipe operator

Gabor Grothendieck ggrothend|eck @end|ng |rom gm@||@com
Mon Dec 7 17:20:52 CET 2020


On Mon, Dec 7, 2020 at 10:11 AM <luke-tierney using uiowa.edu> wrote:
> Or, keeping dplyr but with R-devel pipe and function shorthand:
>
> DF <- "myfile.csv" %>%
>     readLines() |>
>     \(.) gsub(r'{(c\(.*?\)|integer\(0\))}', r'{"\1"}', .) |>
>     \(.) read.csv(text = .) |>
>     mutate(across(2:3, \(col) lapply(col, \(x) eval(parse(text = x)))))
>
> Using named arguments to redirect to the implicit first does work,
> also in magrittr, but for me at least it is the kind of thing I would
> probably regret a month later when trying to figure out the code.

The gsub issue suggests that if one were to start afresh
that the arguments to gsub (and many other R functions)
should be rearranged.  Of course, that is precisely what
the tidyverse did.



More information about the R-devel mailing list