Re: [R] readline in function call with space in prompt.
Hello, Sorry for the delayed reply and thanks for your feedback. I noticed this problem both on Linux and on Windows. Thanks for leading me to the solution. I'm on R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out". A common factor between the Windows and the Linux session is Emacs ESS. I was not able to replicate the problem in a terminal. So yes the issue is likely to lie with Emacs ESS. The versions I'm currently using is linux: ess-version: 18.10.3snapshot [elpa: 20200825.829] (loaded from /home/djj/.emacs.d/elpa/ess-20200825.829/) windows: ess-version: 18.10.3snapshot [elpa: 20201122.814] (loaded from c:/Users/Jeremie/AppData/Roaming/.emacs.d/elpa/ess-20201122.814/) I will report it on the ESS mailing list if need be. Many thanks again, Best regards, -- Jeremie Juste __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] readline in function call with space in prompt.
Not on a machine with latest R at moment so not ruling out something there, but it is working fine for me. Karl R version 4.0.2 (2020-06-22) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19041) -- Message: 9 Date: Tue, 9 Feb 2021 10:21:58 +1300 From: Rolf Turner To: Jeremie Juste Cc: r-help@r-project.org Subject: Re: [R] readline in function call with space in prompt. Message-ID: <20210209102158.5b04117d@rolf-Latitude-E7470> Content-Type: text/plain; charset="windows-1252" On Mon, 08 Feb 2021 14:28:33 +0100 Jeremie Juste wrote: > Hello, > > I have noticed a behavior that I don't understand. When I call the > following function from the prompt. > test <- function(){ > a <- readline("selection: ") > a > } > > > test() > > selection: | > I can only type one character and the readline function exits before > I can press enter. > > however > > test1 <- function(){ > a <- readline("selection:") > a > } > > test1() > > selection:| > works as expected. > > selection: abc[Ret] > > However calling directly readline with a space in the prompt does > what I would expect. > > > a <- readline("selection: ") > > selection: abc[Ret] > > a > > "abc" > > It is the expected behavior or am I missing something? Works fine for me, with or without the space in the prompt string. There *must* be something flaky in your system, but I'm damned if I can come up with any useful suggestions for tracking down just where that flakiness lies. Sorry. Perhaps try re-installing R??? cheers, Rolf Turner -- Honorary Research Fellow Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] readline in function call with space in prompt.
The function test as defined below by Jeremie works as I would have expected for me on Windows so I am unable to replicate the problem there. R version 4.0.3 (2020-10-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19041) Matrix products: default locale: [1] LC_COLLATE=English_United Kingdom.1252 [2] LC_CTYPE=English_United Kingdom.1252 [3] LC_MONETARY=English_United Kingdom.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United Kingdom.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.0.3 On 09/02/2021 09:37, Martin Maechler wrote: Jeremie Juste on Mon, 08 Feb 2021 14:28:33 +0100 writes: > Hello, > I have noticed a behavior that I don't understand. When I call the > following function from the prompt. > test <- function(){ > a <- readline("selection: ") > a > } >> test() >> selection: | > I can only type one character and the readline function exits before I can > press enter. > however > test1 <- function(){ > a <- readline("selection:") > a > } >> test1() >> selection:| > works as expected. >> selection: abc[Ret] > However calling directly readline with a space in the prompt does what I > would expect. >> a <- readline("selection: ") >> selection: abc[Ret] >> a >> "abc" > It is the expected behavior or am I missing something? > Best regards, > Jeremie > -- > Jeremie Juste >> R version 4.0.3 (2020-10-10) Given that the above works fine in Linux (for Jim Lemon and Rolf Turner), could you tell us *how* you use R? In the (Windows) RGui or from Rstudio or ESS or yet another way? Usually the UI (user interface) should not matter, but rather the R version etc. But the UI may be important for a function like readline() which does UI .. Martin __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Michael http://www.dewey.myzen.co.uk/home.html __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] readline in function call with space in prompt.
> Jeremie Juste > on Mon, 08 Feb 2021 14:28:33 +0100 writes: > Hello, > I have noticed a behavior that I don't understand. When I call the > following function from the prompt. > test <- function(){ > a <- readline("selection: ") > a > } >> test() >> selection: | > I can only type one character and the readline function exits before I can > press enter. > however > test1 <- function(){ > a <- readline("selection:") > a > } >> test1() >> selection:| > works as expected. >> selection: abc[Ret] > However calling directly readline with a space in the prompt does what I > would expect. >> a <- readline("selection: ") >> selection: abc[Ret] >> a >> "abc" > It is the expected behavior or am I missing something? > Best regards, > Jeremie > -- > Jeremie Juste >> R version 4.0.3 (2020-10-10) Given that the above works fine in Linux (for Jim Lemon and Rolf Turner), could you tell us *how* you use R? In the (Windows) RGui or from Rstudio or ESS or yet another way? Usually the UI (user interface) should not matter, but rather the R version etc. But the UI may be important for a function like readline() which does UI .. Martin __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] readline in function call with space in prompt.
On Mon, 08 Feb 2021 14:28:33 +0100 Jeremie Juste wrote: > Hello, > > I have noticed a behavior that I don't understand. When I call the > following function from the prompt. > test <- function(){ > a <- readline("selection: ") > a > } > > > test() > > selection: | > I can only type one character and the readline function exits before > I can press enter. > > however > > test1 <- function(){ > a <- readline("selection:") > a > } > > test1() > > selection:| > works as expected. > > selection: abc[Ret] > > However calling directly readline with a space in the prompt does > what I would expect. > > > a <- readline("selection: ") > > selection: abc[Ret] > > a > > "abc" > > It is the expected behavior or am I missing something? Works fine for me, with or without the space in the prompt string. There *must* be something flaky in your system, but I'm damned if I can come up with any useful suggestions for tracking down just where that flakiness lies. Sorry. Perhaps try re-installing R??? cheers, Rolf Turner -- Honorary Research Fellow Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] readline in function call with space in prompt.
Hi Jeremie, Try this: test <- function() { a<-readline("selection: ") return(a) } If it starts working, it could be a difference in the way Windows R handles text input. Both work okay for me on fedora linux. Jim On Tue, Feb 9, 2021 at 12:29 AM Jeremie Juste wrote: > > Hello, > > I have noticed a behavior that I don't understand. When I call the > following function from the prompt. > test <- function(){ > a <- readline("selection: ") > a > } > > > test() > > selection: | > I can only type one character and the readline function exits before I can > press enter. > > however > > test1 <- function(){ > a <- readline("selection:") > a > } > > test1() > > selection:| > works as expected. > > selection: abc[Ret] > > However calling directly readline with a space in the prompt does what I > would expect. > > > a <- readline("selection: ") > > selection: abc[Ret] > > a > > "abc" > > It is the expected behavior or am I missing something? > > Best regards, > Jeremie > -- > Jeremie Juste > > R version 4.0.3 (2020-10-10) > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.