通过命令行安装二进制压缩 R 包
我正在尝试通过命令行在 Windows 7 计算机上安装压缩的二进制 R 包,
R CMD INSTALL packagename
但它不起作用。我读到 CMD INSTALL 不能用于安装二进制包。那么如何通过命令行安装二进制包呢?
I am trying to install zipped binary R packages via command line on a windows 7 machine with
R CMD INSTALL packagename
but it doesn't work. I read that CMD INSTALL can't be used to install binary packages. So how can I install binary packages via command line?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于像我这样的新手来说,一个简单的替代方案是:
file.choose() 命令将显示一个窗口,允许您选择下载文件的 .zip 文件或 tar.gz 文件。
当您在 Windows 计算机上没有足够的权限并像我一样从闪存驱动器运行 R 时,此命令非常有用。
在运行此命令之前,将要安装的 zip 文件重命名为要使用的包名称也很有用。
An alternative for newbies like me that is hassle free would be:
The file.choose() command will show a window allowing you to choose the .zip file or the tar.gz file where you downloaded it.
This command is very useful when you don't have enough rights on a Windows machine and run R from a flash drive like myself.
It is also useful before running this command to RENAME the zip file you are going to install into the package name that you intend to use.
您可以使用 Rscript 前端来运行代码,就像在正在运行的 R 会话中一样。假设您要安装的包是当前工作目录中的
foo.zip
。我可能在这里滥用 Rscript,但它对我有用:如果二进制包不在脚本运行的目录中,则需要提供二进制包的路径。
repos = NULL
是让install.packages()
从本地文件工作的技巧。阅读?install.packages
了解有关您可能想要指定的其他参数的更多信息,尤其是lib
。请注意,执行此操作时,您不会从自动依赖项解析中受益 - 您需要一个repo
,如果您提供一个,R 将尝试下载包。你对
R CMD INSTALL
的看法是正确的; R 安装和管理手册的第 6.3 节中有以下内容:You can use the
Rscript
front end to run code as if it were in a running R session. Say the package you want to install isfoo.zip
in the current working directory. I'm probably abusingRscript
here, but it works for me:You need to supply the path to the binary package if it is not in the directory where there script is running.
repos = NULL
is the trick to getinstall.packages()
to work from a local file. Read?install.packages
for more info on other arguments you might want to specify, especiallylib
. Note that you don't benefit from automatic dependency resolution when doing this - you need arepo
for that and if you supply one, R will try to download packages.You are right about
R CMD INSTALL
; the R Installation and Administration manual has the following in Section 6.3:对@moldovean 的回答的补充:
我曾经保存压缩文件(从临时文件复制到 R 下载文件夹以供将来参考)。
当我将 R 从 2.15.1 更新到 3.0.1 时,我运行以下命令以方便安装:
R 会自动从压缩文件安装所有包。现在我可以只用一个命令更新所有这些(谷歌它)
An addition to @moldovean's answer:
I used to save the zipped file(copy from temp to a R download folder for future reference).
When I updated R from 2.15.1 to 3.0.1, I run these commands for easy installation:
And R installed all packages automatically from zipped files. Now I can update all of them with one command only(google it)