简体   繁体   English

使用 R CMD 检查时避免检查 "\\notrun" 示例

[英]Avoid checking "\notrun" examples when using R CMD check

When I run R CMD check on my package ( Ctrl + Shift + E in RStudio ), it also tests if my examples run without errors.当我在我的包上运行R CMD check时(RStudio 中的Ctrl + Shift + E ),它还测试我的示例是否运行没有错误。

Unfortunately, there are some examples that should not be run in this context, as they involve external files that are relevant for understanding but not for testing.不幸的是,有些示例不应在此上下文中运行,因为它们涉及与理解相关但与测试无关的外部文件。 These are wrapped with \\dontrun{} in the ROxygen header.这些在 ROxygen 标头中用\\dontrun{} dontrun \\dontrun{}包裹。

I know I could use the --no-examples in the R CMD check additional options (RStudio > Build > More > Configure Build Tools), but this would test no example at all, which is not what I want.我知道我可以在R CMD check附加选项(RStudio > Build > More > Configure Build Tools)中使用--no-examples ,但这根本不会测试任何示例,这不是我想要的。

Instead, I'd like R CMD check to run devtools::run_examples(run=FALSE, fresh = T) , so that examples in \\dontrun{} are not ran.相反,我希望R CMD check运行devtools::run_examples(run=FALSE, fresh = T) ,以便不运行\\dontrun{}中的示例。 This command runs perfectly in the console.此命令在控制台中完美运行。

How can I configure R CMD check in RStudio this way?如何以这种方式在 RStudio 中配置R CMD check

Sometimes when you change documentation, such as examples, the old files remain in the man folder of your package.有时,当您更改文档(例如示例)时,旧文件仍保留在包的man文件夹中。 This is why after a change such as wrapping examples in \\dontrun{} , it can make sense to clean up the directory.这就是为什么在诸如在\\dontrun{}包装示例之类的更改之后,清理目录是有意义的。 You can do so with roxygen2 by running:您可以通过运行roxygen2来执行此操作:

roxygen2::roxygenise(clean = TRUE)

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

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