R package CRAN note for package dependencies and warnings in tests

R package CRAN note for package dependencies and warnings in tests

我打算将我的第一个包裹提交给 CRAN。我听说你不应该有任何错误、警告或注释。但是,我收到说明包依赖项过多的注释:

"导入包括 24 个非默认包。 从如此多的包中导入会使包容易受到任何 他们变得不可用。尽可能多地移动到建议和 有条件地使用。"

  1. 关于 CRAN 提交,这个注释是我必须解决的问题吗?
  2. 声明 all/most 使用的软件包可以被包含因为它们维护良好,这有什么不同吗?
  3. 是否可以使用 tidyverse 作为依赖项而不是每个单独的包(我知道这在某种程度上违背了限制的目的;尽管有 20 个包的限制无论如何感觉相当随意并且重点应该还要使用维护良好的软件包)。

测试中的警告

我已经为包创建了测试用例;但是,为了保持大小限制,我需要使用比平时更少的案例;这会在 运行 测试时产生不同的警告。提交 CRAN 时出现这些与测试相关的警告是否可以?

提前致谢! 约翰

在大多数情况下,假设您通过了 R CMD CHECK --as-cran [yourpackage],“注释”不会自动导致审阅者拒绝您的提交。在这种情况下,我会把建议牢记在心。
首先,确定您是否真的、真的需要所有这些导入 ,更不用说 imports 了。这看起来确实是一个非常大的集合。例如,确保您不能调用引用包 A、B、C 和 D 中的某些函数,而不是调用包 K、Q 和 T 中的类似函数(列出您从 A 到 X 的引用)。如果您只使用一个包中的一个独立函数,即一个不依赖于该包中任何其他项目的函数,请将源代码从那里复制到您的包的源目录中,并注明出处。

其次,只有在您的函数需要它们才能执行时才导入它们,而不管它们的参数列表如何。仅支持特定“模式”或选项的包应移至 Suggests .

下面引用了文档“R_exts”的相关部分,希望您已阅读。

All packages that are needed7 to successfully run R CMD check on the package must be listed in one of ‘Depends’ or ‘Suggests’ or ‘Imports’. Packages used to run examples or tests conditionally (e.g. via if(require(pkgname))) should be listed in ‘Suggests’ or ‘Enhances’. (This allows checkers to ensure that all the packages needed for a complete check are installed.) In particular, packages providing “only” data for examples or vignettes should be listed in ‘Suggests’ rather than ‘Depends’ in order to make lean installations possible. Version dependencies in the ‘Depends’ and ‘Imports’ fields are used by library when it loads the package, and install.packages checks versions for the ‘Depends’, ‘Imports’ and (for dependencies = TRUE) ‘Suggests’ fields. It is increasingly important that the information in these fields is complete and accurate: it is for example used to compute which packages depend on an updated package and which packages can safely be installed in parallel. This scheme was developed before all packages had namespaces (R 2.14.0 in October 2011), and good practice changed once that was in place. Field ‘Depends’ should nowadays be used rarely, only for packages which are intended to be put on the search path to make their facilities available to the end user (and not to the package itself): for example it makes sense that a user of package latticeExtra would want the functions of package lattice made available. Almost always packages mentioned in ‘Depends’ should also be imported from in the NAMESPACE file: this ensures that any needed parts of those packages are available when some other package imports the current package. The ‘Imports’ field should not contain packages which are not imported from (via the NAMESPACE file or :: or ::: operators), as all the packages listed in that field need to be installed for the current package to be installed. (This is checked by R CMD check.) R code in the package should call library or require only exceptionally. Such calls are never needed for packages listed in ‘Depends’ as they will already be on the search path. It used to be common practice to use require calls for packages listed in ‘suggests’ in functions which used their functionality, but nowadays it is better to access such functionality via :: calls.