Rstudio 的控制台在交互模式测试时卡住

发布于 2025-01-15 17:58:12 字数 165 浏览 3 评论 0原文

我尝试在 Rstudio 中测试交互模式:

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

但是控制台卡住并且不接受任何命令。之后我什至无法退出此模式,并且必须重新启动整个 Rstudio。 我做错了什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

网名女生简单气质 2025-01-22 17:58:12

stdin() 读取,而不是 file("stdin")

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

?stdin 读取:

stdin() 指的是“控制台”,而不是进程的 C 级 stdin。这种区别在 GUI 控制台(可能没有活动的 stdin,如果有的话可能不会连接到控制台输入)以及嵌入式应用程序中很重要。如果您想访问 C 级文件流 stdin,请使用 file("stdin")

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文