From m@echler @ending from @t@t@m@th@ethz@ch  Mon May 28 16:38:35 2018
From: m@echler @ending from @t@t@m@th@ethz@ch (Martin Maechler)
Date: Mon, 28 May 2018 16:38:35 +0200
Subject: [Rd] readLines function with R >= 3.5.0
In-Reply-To: <f3388993-5e20-d7e5-346a-785d33fab27b@daqana.com>
References: <32da856c-a60a-974f-65ab-d7123e12e813@daqana.com>
 <23307.48529.773039.904392@stat.math.ethz.ch>
 <23307.49323.908367.788461@stat.math.ethz.ch>
 <CABtg=KkuVHoX1tZ=+Lr7mDFrXvn5zdf3+Wmqhnv58GXZJS2KwQ@mail.gmail.com>
 <f3388993-5e20-d7e5-346a-785d33fab27b@daqana.com>
Message-ID: <23308.5227.150150.598800@stat.math.ethz.ch>

>>>>> Ralf Stubner 
>>>>>     on Mon, 28 May 2018 12:13:57 +0200 writes:

    > On 28.05.2018 11:07, G?bor Cs?rdi wrote:
    >> stdin() is not the same as file("stdin"), see the note in ?stdin.

Of course it is not the same, otherwise using one for the other
had no effect, but you are right:
it is *NOT* a solution to the problem

    > In particular stdin() works in an interactive session but not when R -f
    > / Rscript is used, since it does not wait for the user to input anything:

    > $ R -f readLines.R

    > R version 3.5.0 (2018-04-23) -- "Joy in Playing"
    > Copyright (C) 2018 The R Foundation for Statistical Computing
    > Platform: x86_64-pc-linux-gnu (64-bit)
    > [...]
    >> create_matrix <- function() {
    > +   cat("Write the numbers of vertices: ")
    > +   user_input <- readLines(stdin(), n=1)
    > +   user_input <- as.numeric(user_input)
    > +   print(user_input)
    > +   }
    >> create_matrix()
    > Write the numbers of vertices: numeric(0)
    >> 

oh dear...  yes, that is true ..


    >>>>>>>> Martin Maechler
    >>>>>>>> on Mon, 28 May 2018 10:28:01 +0200 writes:
    >>> > It "works" if you additionally (the [Enter], i.e., EOL) you also
    >>> > "send" an EOF -- in Unix alikes via  <Ctrl>-D

    > From my point of view this is a reasonable workaround for now.

I'm glad to hear that.

Then, I now do think this needs to be dealt with as a bug
(but I'm not delving into fixing it!)

Martin


    > Thanks
    > Ralf

    > -- 
    > Ralf Stubner
    > Senior Software Engineer / Trainer

    > daqana GmbH
    > Dortustra?e 48
    > 14467 Potsdam

    > T: +49 331 23 61 93 11
    > F: +49 331 23 61 93 90
    > M: +49 162 20 91 196
    > Mail: ralf.stubner at daqana.com

    > Sitz: Potsdam
    > Register: AG Potsdam HRB 27966 P
    > Ust.-IdNr.: DE300072622
    > Gesch?ftsf?hrer: Prof. Dr. Dr. Karl-Kuno Kunze

    > x[DELETED ATTACHMENT signature.asc, application/pgp-signature]
    > ______________________________________________
    > R-devel at r-project.org mailing list
    > https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] readLines function with R >= 3.5.0
Martin Maechler