有没有办法使用 emacs 安装 R 包?
我正在使用 ESS,但每次需要安装新软件包时,我都必须使用 R gui。有没有办法在不离开 emacs 的情况下做到这一点?
I am using ESS, but every time I need to install a new package I have to use R gui. Isn't there a way to do this without leaving emacs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
来自
帮助(启动)
:From
help(Startup)
:Cc Ce i
加载所有包需要几秒钟的时间。
C-c C-e i
It will take a few seconds to load all packages.
http://www.emacswiki.org/emacs/anything-R.el
对我来说效果很好。
http://www.emacswiki.org/emacs/anything-R.el
works well for me.
如果您不记得包安装的快捷方式,可以通过 方便的命令主菜单。
如果您在下级 R 缓冲区中键入
,
作为第一个字符(即在进程标记处),则会触发迷你缓冲区中的便捷命令菜单,如下图所示:注意如何交互式地选择菜单项通过输入首字母(就像使用 Emacs isearch 一样)。当然,您可以简单地使用箭头。
选择
install.packages
(输入i
,然后输入enter
就足够了)。在随后的菜单中,您将看到 CRAN 镜像列表:
选择一个方便的镜像。 ESS 将获取可用的包
然后您将看到可安装软件包的列表。
选择您需要的一个即可完成。
请注意,当您在当前会话中第二次安装软件包时,系统不会要求您重新选择镜像。
如果您不熟悉 ESS 方便的命令,您可能会在这里发现许多其他命令非常...非常方便。特别是,就此处的主题而言,
library
命令可能会有所帮助,因为您可以享受自动完成功能,当您需要加载包但您不记得其拼写时也很有用。您可能想要使用 Emacs 中的标准 R GUI 对话框。
在这种情况下,至少在 Windows 中,要正确显示对话框,请使用:
If you don't remember the shortcut for package setup, you can go through the Handy commands main menu.
If you type
,
in the inferior R buffer as the first character (i.e. at the process marker), you trigger the handy commands menu in the minibuffer, like in the following figure:Note how you can interactively select menu items by typing the initial characters (like with Emacs isearch). Of course you can simply use the arrows.
Select
install.packages
(typingi
followed byenter
should be enough).In the subsequent menu, you are presented with the CRAN mirror list:
Select a convenient mirror. ESS will fetch the available packages
You are then presented with the list of installable packages.
Select the one that you need and you are done.
Note that the second time you install a package in the current session you are not requested to reselect the mirror.
If you are not familiar with ESS handy commands, you might find here many other commands very ... well handy. Particularly, as regards the subject matter here, the
library
command might help, because you can enjoy auto-completion, useful also when you need to load a package, but you do not remember its spelling.You might want to use the standard R GUI dialogues from Emacs.
In this case, at least in Windows, to display properly the dialogue boxes, use: