Skip to content
Back to formatted view

Raw Message

Message-ID: <CAP01uRmP=1vtHUeqS6yAX1BeP1am_2auZCEFbgzm6kb_nafDzA@mail.gmail.com>
Date: 2020-12-07T16:20:52Z
From: Gabor Grothendieck
Subject: [External] Re: New pipe operator
In-Reply-To: <alpine.DEB.2.21.2012070908010.3377@luke-Latitude-7480>

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.