如何告诉 CRAN 自动安装软件包依赖项?

我用 R 语言开发了一个软件包,当我检查并在我的本地计算机上构建它时,它能正常工作。但是当我在 CRAN 中尝试它时,我得到一个包依赖性错误。我的软件包依赖于其他软件包的两个函数。

如果我使用 Dependsimportsdescription下列出其他软件包,它会自动与新软件包一起安装吗?或者我需要在使用其他包的函数下显式调用函数 install.packages("packagename")吗。如果这一切都是错误的,什么是最好的方法来解决 R的包依赖,以通过 R CMD checkbuild测试,并提交给 CRAN?

谢谢你。

127655 次浏览

用你自己的系统试试

install.packages("foo", dependencies=...)

dependencies=参数一起记录为

dependencies: logical indicating to also install uninstalled packages
which these packages depend on/link to/import/suggest (and so
on recursively).  Not used if ‘repos = NULL’.  Can also be a
character vector, a subset of ‘c("Depends", "Imports",
"LinkingTo", "Suggests", "Enhances")’.


Only supported if ‘lib’ is of length one (or missing), so it
is unambiguous where to install the dependent packages.  If
this is not the case it is ignored, with a warning.


The default, ‘NA’, means ‘c("Depends", "Imports",
"LinkingTo")’.


‘TRUE’ means (as from R 2.15.0) to use ‘c("Depends",
"Imports", "LinkingTo", "Suggests")’ for ‘pkgs’ and
‘c("Depends", "Imports", "LinkingTo")’ for added
dependencies: this installs all the packages needed to run
‘pkgs’, their examples, tests and vignettes (if the package
author specified them correctly).

所以你可能需要一个值 TRUE

在您的包中,列出 Depends:中所需的内容,请参见 编写 R 扩展程序 手册,这一点非常清楚。

另一种可能性是选择右下角 R 包安装程序中的“安装依赖项”复选框:

enter image description here