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

问题描述 投票:68回答:2

我在R中开发了一个程序包,当我在本地计算机中检查并构建它时,它可以正常工作。但是,当我在CRAN中尝试时,出现了程序包依赖性错误。我的程序包依赖于其他程序包的两个功能。

如果我使用descriptionDepends列出imports下的其他软件包,是否将其与新软件包一起自动安装?还是我需要在使用其他软件包的函数下显式调用函数install.packages("packagename")。如果这一切都是错误的,为了通过RR CMD check测试并提交给CRAN,解决build中的程序包依赖性的最佳方法是什么?

谢谢。

r cran r-forge
2个回答
73
投票

在您自己的系统上,尝试

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:中需要的内容,请参阅Writing R Extensions手册,对此非常清楚。


3
投票

另一种可能性是选中R软件包安装程序右下角的Install Dependencies复选框:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.