通过命令行安装二进制压缩的R软件包 [英] Install binary zipped R package via command line

查看:355
本文介绍了通过命令行安装二进制压缩的R软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过Windows 7机器上的命令行通过命令行安装压缩的二进制R软件包

I am trying to install zipped binary R packages via command line on a windows 7 machine with

R CMD INSTALL packagename

但是它不起作用.我读到CMD INSTALL不能用于安装二进制软件包.那么如何通过命令行安装二进制软件包?

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?

推荐答案

您可以使用Rscript前端来运行代码,就像在运行的R会话中一样.假设您要安装的软件包在当前工作目录中为foo.zip.我可能在这里滥用Rscript,但这对我有用:

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 is foo.zip in the current working directory. I'm probably abusing Rscript here, but it works for me:

Rscript -e "install.packages('foo.zip', repos = NULL)"

如果二进制程序包的路径不在运行脚本的目录中,则需要提供该路径. repos = NULL是使install.packages()从本地文件工作的技巧.阅读?install.packages以获得有关您可能想要指定的其他参数的更多信息,尤其是lib.请注意,执行此操作不会使您受益于自动依赖项解析-为此,您需要repo,如果提供了repo,R将尝试下载软件包.

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 get install.packages() to work from a local file. Read ?install.packages for more info on other arguments you might want to specify, especially lib. Note that you don't benefit from automatic dependency resolution when doing this - you need a repo for that and if you supply one, R will try to download packages.

您对R CMD INSTALL是正确的; 《 R安装和管理》手册在第6.3 部分中具有以下内容:

You are right about R CMD INSTALL; the R Installation and Administration manual has the following in Section 6.3:

要以类似Unix的方式从源代码安装软件包

To install packages from source in a Unix-alike use

    R CMD INSTALL -l /path/to/library pkg1 pkg2 ...

这篇关于通过命令行安装二进制压缩的R软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆