简体   繁体   English

从 R 中的源安装时的 Package 依赖项

[英]Package dependencies when installing from source in R

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 ? 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.可能让它工作的方法是 package 安装脚本。 Is that possible?那可能吗? Am I completely missing something here and there is a mechanism to install from source AND automagically download and install dependencies?我是否在这里完全遗漏了一些东西,并且有一种从源代码安装并自动下载和安装依赖项的机制?

The devtools package has a function install . devtools package 有一个 function install If used on a directory containing the source code for an R package, it will install that package and download any dependencies from CRAN.如果在包含 R package 的源代码的目录中使用,它将安装 package 并从 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.您可以创建自己的存储库并将repos设置为查找包的位置的向量,它将从您自己的存储库开始,然后包含指向 CRAN 镜像的链接。 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您可以使用

  devtools::install_local(path)

It can automatically download all the dependencies.它可以自动下载所有依赖项。

If you have a Github account myname , push your R package to a repo mypackage .如果您有Github帐户myname ,请将您的 R package 推送到 repo mypackage Then just call devtools::install_github("myname/mypackage") .然后只需调用devtools::install_github("myname/mypackage") Package mypackage will be downloaded and installed as will all the dependencies listed under Imports in the DESCRIPTION file. Package mypackage将被下载并安装,描述文件中 Imports 下列出的所有依赖项也将被下载和安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM