简体   繁体   中英

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?

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") .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM