在 R 中从源安装时的包依赖项
只是确认:如果我将 R 包作为 ZIP/TAR 分发,那么安装该包将不会自动下载/安装依赖项,因为我必须在 install.packages()
中设置 repos = NULL
如果 repos = NULL
则不使用 code> 和依赖项参数?可能使其发挥作用的方法是打包安装脚本。这可能吗?我是否在这里完全错过了一些东西,并且有一种从源安装并自动下载和安装依赖项的机制?
Just confirming: If I distribute my R package as ZIP/TAR then installing the package will not automatically download/install dependencies because I have to set repos = NULL
in install.packages()
and dependencies parameter is not used if repos = NULL
? The way to possibly get this to work is to package an install script. Is that possible? Am I completely missing something here and there is a mechanism to install from source AND automagically download and install dependencies?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
devtools
软件包有一个install
函数。如果在包含 R 包源代码的目录上使用,它将安装该包并从 CRAN 下载所有依赖项。The
devtools
package has a functioninstall
. If used on a directory containing the source code for an R package, it will install that package and download any dependencies from CRAN.您可以创建自己的存储库,并将
repos
设置为查找包的位置的向量,它将从您自己的存储库开始,然后包含指向 CRAN 镜像的链接。这就是我所做的,而且效果非常好,因为这样我就可以轻松地与其他人共享我的包,并从我碰巧使用的任何计算机上更新它们。You could make your own repository and set
repos
to be a vector of the places to look for packages, where it would start with your own repository and then include a link to a CRAN mirror. This is what I do and it works quite nicely, as then I can easily share my packages with others and update them from whatever computer I happen to be on.您可以使用
它可以自动下载所有依赖项。
You can use
It can automatically download all the dependencies.
如果您有 Github 帐户myname,请将您的 R 包推送到存储库我的包。然后只需调用 devtools::install_github("myname/mypackage") 即可。将下载并安装包 mypackage,以及 DESCRIPTION 文件中 Imports 下列出的所有依赖项。
If you have a Github account myname, push your R package to a repo mypackage. Then just call
devtools::install_github("myname/mypackage")
. Package mypackage will be downloaded and installed as will all the dependencies listed under Imports in the DESCRIPTION file.