简体   繁体   English

R package CRAN 注意 package 测试中的依赖项和警告

[英]R package CRAN note for package dependencies and warnings in tests

I'm planning to submit my first package to CRAN.我打算将我的第一个 package 提交给 CRAN。 I've heard that you should not have any errors, warnings or notes.我听说你不应该有任何错误、警告或注释。 However, I get the Note stating that there are too many package dependencies:但是,我收到说明 package 依赖项太多的说明:

"Imports includes 24 non-default packages. Importing from so many packages makes the package vulnerable to any of them becoming unavailable. Move as many as possible to Suggests and use conditionally." “Imports 包括 24 个非默认包。从如此多的包中导入会使 package 容易受到其中任何一个变得不可用的影响。尽可能多地移至 Suggests 并有条件地使用。”

  1. Is this note something I have to address in regard to a CRAN submission?关于 CRAN 提交,我必须解决这个注释吗?
  2. Does it make a difference to state that all/most packages used is OK to be included because they are well-maintained?使用的所有/大多数软件包都可以包含在内,因为它们维护良好,这对 state 有影响吗?
  3. Is it possible to use tidyverse as a dependency instead of each individual package (I understand that this to some extent defeats the purpose with the limit; although having a 20-package-limit feels rather arbitrary anyway and the focus should also be on using well-maintained packages).是否可以将 tidyverse 用作依赖项而不是每个单独的 package (我知道这在某种程度上违背了限制的目的;尽管无论如何有 20 包限制感觉相当随意,重点也应该放在使用良好- 维护的软件包)。

Warnings in tests测试中的警告

I have created test cases for the package;我为 package 创建了测试用例; however, in order to keep the size limit I need to get use fewer cases than normally used;但是,为了保持大小限制,我需要使用比通常使用的更少的案例; and this creates different warnings when running the test.这会在运行测试时产生不同的警告。 Is this OK to have these test related warnings when submitting CRAN?提交 CRAN 时是否可以有这些与测试相关的警告?

Thanks in advance!提前致谢! John约翰

In most cases, "Notes" won't automatically cause a reviewer to reject your submission, assuming you otherwise passed R CMD CHECK --as-cran [yourpackage] .在大多数情况下,假设您通过了R CMD CHECK --as-cran [yourpackage] ,“注释”不会自动导致审阅者拒绝您的提交。 In this case, I would take the advice to heart.在这种情况下,我会把建议牢记在心。
First, decide if you really, truly need all those imports at all , let alone as imports .首先,决定你是否真的,真的需要所有这些进口,更不用说imports了。 That does seem like a very large collection.这看起来确实是一个非常大的集合。 Make sure you can't, for example, call some functions in referenced packages A, B, C, and D rather than similar functions in packages K, Q, and T (listing your references from A to X).例如,确保您不能调用引用的包 A、B、C 和 D 中的某些函数,而不是调用包 K、Q 和 T 中的类似函数(列出从 A 到 X 的引用)。 If you're only using one standalone function from a package, ie a function which doesn't depend on any other item in that package, copy the source code from there, with attribution, into your package's source directory. If you're only using one standalone function from a package, ie a function which doesn't depend on any other item in that package, copy the source code from there, with attribution, into your package's source directory.

Second, Only import them if they're needed for your functions to be able to execute regardless of their argument lists.其次,仅当您的函数需要它们才能执行时才导入它们,而不管它们的参数列表如何。 Packages which only support specific "modes" or options should be moved to Suggests .仅支持特定“模式”或选项的软件包应移至Suggests

The relevant portion of the document "R_exts", which I hope you've read, is quoted below.我希望您已阅读文档“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'.成功运行 R CMD 所需的所有包 7 检查 package 必须列在“IDepends”或“Suggests”或“之一”中。 Packages used to run examples or tests conditionally (eg via if(require(pkgname))) should be listed in 'Suggests' or 'Enhances'.用于有条件地运行示例或测试的包(例如,通过 if(require(pkgname)))应列在“建议”或“增强”中。 (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.库在加载 package 时使用“Depends”和“Imports”字段中的版本依赖关系,并且 install.packages 检查“Depends”、“Imports”和(对于依赖项 = TRUE)“Suggests”字段的版本。 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.这些字段中的信息的完整性和准确性变得越来越重要:例如,它用于计算哪些软件包依赖于更新的 package 以及哪些软件包可以安全地并行安装。 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.该方案是在所有包都有命名空间之前开发的(2011 年 10 月的 R 2.14.0),并且一旦到位,良好的实践就会改变。 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.现在应该很少使用字段“Depends”,仅用于旨在将其设施提供给最终用户(而不是 package 本身)的包:例如,有意义的用户package latticeExtra 需要 package lattice 的功能可用。 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.几乎所有在“Depends”中提到的包也应该从 NAMESPACE 文件中导入:这样可以确保当其他一些 package 导入当前的 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. 'Imports' 字段不应包含不是从(通过 NAMESPACE 文件或:: 或::: 运算符)导入的包,因为需要安装该字段中列出的所有包才能安装当前的 package。 (This is checked by R CMD check.) R code in the package should call library or require only exceptionally. (这由 R CMD 检查检查。)R 代码在 ZEFE90A8E604A 库中调用或仅需要 67C840D78ZD0。 Such calls are never needed for packages listed in 'Depends' as they will already be on the search path. 'Depends' 中列出的包永远不需要这样的调用,因为它们已经在搜索路径上。 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.在使用其功能的函数中对“建议”中列出的包使用 require 调用是一种常见的做法,但现在最好通过:: 调用来访问此类功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM