'Rstudio's console stuck while interactive mode testing
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?
Solution 1:[1]
Read from stdin(), not file("stdin"):
ans <- readLines(stdin(), n = 1)
From ?stdin:
stdin()refers to the 'console' and not to the C-levelstdinof the process. The distinction matters in GUI consoles (which may not have an activestdin, 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 streamstdin, usefile("stdin").
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mikael Jagan |
