From iuke-tier@ey m@iii@g oii uiow@@edu  Tue Aug 10 22:14:11 2021
From: iuke-tier@ey m@iii@g oii uiow@@edu (iuke-tier@ey m@iii@g oii uiow@@edu)
Date: Tue, 10 Aug 2021 15:14:11 -0500 (CDT)
Subject: [Rd] 
 [External]  problem with pipes, textConnection and read.dcf
In-Reply-To: <CAP01uRn+6zWEgmyGfNTb3aJJoLCy8mbhJFj6SiWWBktmXwsncA@mail.gmail.com>
References: <CAP01uRn+6zWEgmyGfNTb3aJJoLCy8mbhJFj6SiWWBktmXwsncA@mail.gmail.com>
Message-ID: <alpine.DEB.2.22.394.2108101452480.3514@luke-Latitude-7480>

Not an issue with pipes. The pipe just rewrites the expression to a
nested call and that is then evaluated. The call this produces is

> quote(L |>
+    gsub(pattern = " ", replacement = "") |>
+    gsub(pattern = " ", replacement = "") |>
+    textConnection() |>
+    read.dcf())
read.dcf(textConnection(gsub(gsub(L, pattern = " ", replacement = ""),
     pattern = " ", replacement = "")))

If you run that expression, or just the argument to read.dcf, then you
get the error you report. So the issue is somewhere in textConnection().
This produces a similar message:

read.dcf(textConnection(c(L, "aaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbb", "cccccccccccccccc", "ddddddddddddddddddd")))

File a bug report and someone who understands the textConnection()
internals better than I do can take a look.

Best,

luke

On Tue, 10 Aug 2021, Gabor Grothendieck wrote:

> This gives an error bit if the first gsub line is commented out then there is no
> error even though it is equivalent code.
>
>  L <- c("Variable:id", "Length:112630     ")
>
>  L |>
>    gsub(pattern = " ", replacement = "") |>
>    gsub(pattern = " ", replacement = "") |>
>    textConnection() |>
>    read.dcf()
>  ## Error in textConnection(gsub(gsub(L, pattern = " ", replacement = ""),  :
>  ##  argument 'object' must deparse to a single character string
>
> That is this works:
>
>  L |>
>    # gsub(pattern = " ", replacement = "") |>
>    gsub(pattern = " ", replacement = "") |>
>    textConnection() |>
>    read.dcf()
>  ##      Variable Length
>  ## [1,] "id"     "112630"
>
>  R.version.string
>  ## [1] "R version 4.1.0 RC (2021-05-16 r80303)"
>  win.version()
>  ## [1] "Windows 10 x64 (build 19042)"
>
>

-- 
Luke Tierney
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:   luke-tierney at uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



[Rd] [External] problem with pipes, textConnection and read.dcf
iuke-tier@ey m@iii@g oii uiow@@edu