用户输入和 ESS
当您要求 ESS 从缓冲区(Cc、Cb 或类似)评估以下内容时,
par(ask=TRUE)
plot(1,1)
plot(2,1)
解释器会进入无限循环,因为 ESS 使用参数 --no-readline 启动 R 会话。这个循环可以用 Cg 来打破,但是有没有办法让解释器真正请求用户输入呢?
When you ask ESS to evaluate the following from a buffer (C-c, C-b, or similar)
par(ask=TRUE)
plot(1,1)
plot(2,1)
The interpreter goes into a infinite loop because ESS starts the R session with the argument --no-readline. The loop can be broken with C-g, but is there any way to get the interpreter to actually request user input?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决方案是编辑
ess-rd.el
并删除给R
的硬编码--no-runtime
选项,它是行最新实施的127。更改
为
如果有编译版本,则必须编译
.el
以生成并替换二进制.elc
文件。该文件可能位于(目录位置取决于您的操作系统)
site-lisp 目录中。在 emacs 中编辑
.el
文件 (^X^F),然后执行Mx byte-compile-file
生成.elc
。如果您是从整个 zip/tar 源代码包安装的,则位于
lisp
目录中。在这种情况下,更改后,执行make
,然后执行make install
。当然,您需要对
.el
和.elc
文件具有write
访问权限。如果您对
.el
文件的编译感到不舒服,您可以简单地将其删除 (.elc
) 并仅使用.el
> 版本(应该只有轻微的性能差异)。A solution is to edit
ess-r-d.el
and remove the hard-coded--no-runtime
option given toR
, it is line 127 of the latest implementation.Change
to
If there is a compiled version, you have to compile the
.el
to generate and replace the binary.elc
file.The file may be (the location of the directory depends on your OS)
in the
site-lisp
directory. Edit the.el
file in emacs (^X^F) then doM-x byte-compile-file
to generate the.elc
.if you installed from the whole zip/tar source package, in the
lisp
directory. In this case, after the change, perform amake
followed with amake install
.You need of course to have
write
access to the.el
and.elc
files.If you do not feel comfortable with the compilation of the
.el
file, you may simply remove it (.elc
) and use only the.el
version (should be only a slight performance difference).(从 Google 和 RSiteSearches 收集的策略):
您是否在任何会话窗口中看到提示:“按 Return”?如果是这样的话……打。
如果没有,请尝试单击绘图窗口。
如果失败了,你应该用 cG 重新获得控制权。
编辑:进一步的策略,诚然没有解决 ESS 非交互性问题:如果你想保留用户输入,那么可以使用 readLines:
(Strategies gathered from Google and RSiteSearches):
Do you see the prompt : "hit Return" in any of your session windows? If so ... hit .
If not, then try clicking in the plot window.
And if that fails, you should get control back with c-G.
Edit: A further strategy, admittedly not solving the ESS-non-interactivity problem: If you want to hold for user input, then readLines can be used: