Home > front end >  Rstudio's console stuck while interactive mode testing
Rstudio's console stuck while interactive mode testing

Time:03-21

I try to test an interactive mode in Rstudio:

ans <- readLines("stdin", n = 1)
print(ans)

However the console gets stuck and not accepting any commands. I cannot even quit this mode after that and have to reboot the entire Rstudio. What I do wrong?

CodePudding user response:

Read from stdin(), not file("stdin"):

ans <- readLines(stdin(), n = 1)

From ?stdin:

stdin() refers to the 'console' and not to the C-level stdin of the process. The distinction matters in GUI consoles (which may not have an active stdin, and if they do it may not be connected to console input), and also in embedded applications. If you want access to the C-level file stream stdin, use file("stdin").

  • Related