如何在emacs的ESS会话中指定打开的R版本?

3
当我想在emacs中打开一个R会话时,我使用“M-x R”。然而,我们的服务器上既有/usr/bin/R中的R 2.12,也有/usr/local/bin/R中的R 2.15。实际上,如果我询问“whereis R”,我会得到以下结果:
$ whereis R
R: /usr/bin/R /usr/local/bin/R /usr/local/bin/R2.15 /usr/local/bin/R2.12 
/usr/local/bin/R2.7 /usr/include/R /usr/share/R /usr/share/man/man1/R.1.gz

当我尝试从.bashrc导出“R_HOME=/usr/local/bin/R2.15”时,emacs会显示“警告:忽略R_HOME的环境值”

有没有办法选择启动哪个R实例?当前,在命令行输入R时会启动2.15版本,即使使用“M-x R”启动的是2.12版本。

1个回答

4

非 ESS 解决方案是确保你的 PATH 相同,并且所需版本排在第一位。似乎启动 Shell 和启动 Emacs 之间存在差异。你可以使用其 PATH 从 Shell 启动 Emacs。

ESS 的解决方案可能涉及设置某些神奇变量...... 在 Windows 上,我们经常直接设置二进制文件。这里的 Lisp 代码如下:

;; If you wish to call other versions of R on a Unix system, ESS
;; should auto-detect other versions of R, according to matches to the
;; variable `ess-r-versions' as described in its docstring.  Consider
;; changing that variable rather than changing inferior-R-program-name
;; if your version of R is not already auto-detected.
;;(setq-default inferior-R-program-name "R")        ; unix systems

所以它应该可以正常工作。我在环境变量PATH中只保留了R,另一个没加进去,所以我无法为您测试这个问题。但您可以尝试调整ess-r-version和/或inferior-R-program-name


添加 (setq-default inferior-R-program-name "R2.15") 就可以了!感谢您帮我解决这个问题。 - Abe
在Windows上,这个工作(根据您的安装调整路径到R,避免路径中的空格):(add-to-list 'load-path "c:/emacs/site-lisp/ess/") (autoload 'R-mode "ess-site.el" "ESS" t) (add-to-list 'auto-mode-alist '("\.R$" . R-mode)) (setq inferior-R-program-name "c:/math/R323/bin/R"); 任何其他路径到R都会使emacs-24.5.1在windows7上挂起,从http://vgoulet.act.ulaval.ca/en/emacs/windows/获取 - mosh

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接