From ggrothend|eck @end|ng |rom gm@||@com  Mon Dec  7 17:20:52 2020
From: ggrothend|eck @end|ng |rom gm@||@com (Gabor Grothendieck)
Date: Mon, 7 Dec 2020 11:20:52 -0500
Subject: [Rd] [External] Re: New pipe operator
In-Reply-To: <alpine.DEB.2.21.2012070908010.3377@luke-Latitude-7480>
References: <e55c2093-0bb5-5f9b-5521-0ca8bdf35953@gmail.com>
 <CALyqOb8c1hHOSaMV+fqXTwpeOsP--KJ_t-oeqMYYafVXeNpqZg@mail.gmail.com>
 <7586e034-e287-0970-6480-f82d747b5445@gmail.com>
 <CADfFDC7bT58_+52uvmpHuMMQRNbbmqV3_7t_fc4sgJ_Esw=xag@mail.gmail.com>
 <CAJmOi+PO_8XDC23=rT=pQ76ENL=gx2V-41ax2fHSVs87xURcEA@mail.gmail.com>
 <alpine.DEB.2.21.2012051203250.3003@luke-Latitude-7480>
 <CAP01uRmd0tRM4xYnegK=YijJv6htqq+fuOwBMBns--0+2a7Opw@mail.gmail.com>
 <alpine.DEB.2.21.2012070908010.3377@luke-Latitude-7480>
Message-ID: <CAP01uRmP=1vtHUeqS6yAX1BeP1am_2auZCEFbgzm6kb_nafDzA@mail.gmail.com>

On Mon, Dec 7, 2020 at 10:11 AM <luke-tierney at 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.



[Rd] [External] Re: New pipe operator
Gabor Grothendieck