从 CRAN 镜像安装具有依赖项的本地 R 包 [英] Install a local R package with dependencies from CRAN mirror

查看:26
本文介绍了从 CRAN 镜像安装具有依赖项的本地 R 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了一个 R 包,即我有 mypackage.tar.gz 文件.这个包依赖于其他几个包,都可以从任何 CRAN 镜像下载和安装.

I have built an R package, i.e. I have the mypackage.tar.gz file. This package depends on several other packages, all downloadable and installable from any CRAN mirror.

现在我想在尚未安装依赖项的系统上安装此包,我希望在我安装包时自动下载并安装依赖项.

Now I want to install this package on a system where the dependencies are not yet installed, and I would like that the dependencies will be downloaded and installed automatically when I install my package.

我试过了:

install.packages("mypackage.tar.gz",type="source",dependencies=TRUE,repos="http://a.cran.mirror")

但它在镜像上搜索 mypackage.tar.gz (显然它没有找到),而如果我设置 repos=NULL 它正确地尝试安装本地包文件(如文档所述),但显然它没有找到依赖包.

but it searches for mypackage.tar.gz on the mirror (and obviously it does not find), while if I set repos=NULL it correctly tries to install the local package file (as documented), but obviously it does not find the dependencies packages.

所以我的问题是:有没有办法执行混合"安装(具有在线依赖项的本地包)或唯一的方法是手动安装所有依赖项?

推荐答案

您可以使用 devtools 包中的 install.只需运行 install("<你的包目录>", dependencies = TRUE).它的帮助说明:

You could use install from the devtools package. Just run install("<directory of your package>", dependencies = TRUE). Its help states:

使用 R CMD INSTALL 安装包.如果尚未安装,还将尝试从 CRAN 安装包的依赖项.

Uses R CMD INSTALL to install the package. Will also try to install dependencies of the package from CRAN, if they're not already installed.

这篇关于从 CRAN 镜像安装具有依赖项的本地 R 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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