gpt4 book ai didi

r - 如何告诉CRAN自动安装包依赖项?

转载 作者:行者123 更新时间:2023-12-01 17:45:44 25 4
gpt4 key购买 nike

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

如果我使用 Dependsimportsdescription 下列出其他软件包,它会自动与新软件包一起安装吗?或者我是否需要在我使用其他包的函数下显式调用函数 install.packages("packagename") 。如果这一切都是错误的,那么解决 R 中的包依赖关系以便通过 R CMD 检查和构建测试并提交的最佳方法是什么到克兰?

谢谢。

最佳答案

在您自己的系统上尝试

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

使用 dependency= 参数记录为

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手册对此非常清楚。

关于r - 如何告诉CRAN自动安装包依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14171148/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com