简体   繁体   English

忽略编织 R markdown (Rmd) 文件时发生的所有错误?

[英]Ignore all errors occurring when knitting R markdown (Rmd) file?

I know how to ignore R errors when knitting , but is it possible to knit the entire markdown doc (or as much of it as possible) whilst ignoring all errors that occur whilst knitting?我知道如何在编织时忽略R错误,但是是否可以在忽略编织时发生的所有错误的同时编织整个降价文档(或尽可能多的文档)?

For example, if a package was missing, have the doc knit anyway (as best it can).例如,如果缺少一个包,无论如何都要编织文档(尽其所能)。

As an example use case, when you want to quickly knit an Rmd (possible just to quickly check something), but some other issues have occurred that you know don't affect the part you're wishing to look at.作为一个示例用例,当您想快速编织一个 Rmd(可能只是为了快速检查某些东西),但发生了一些您知道不会影响您希望查看的部分的其他问题时。

You can set the document to not to stop on errors.您可以将文档设置为不因错误而停止。

knitr::opts_chunk$set(
  error = TRUE, # do not interrupt in case of errors
)

This is also true for warning messages and to include the code in the knited document.对于警告消息和在编织文档中包含代码也是如此。

knitr::opts_chunk$set(
  warning = TRUE, # show warnings
  message = TRUE, # show messages
  error = TRUE, # do not interrupt generation in case of errors,
  echo = TRUE  # show R code
)

If you want to do it locally you can add error=TRUE to an specific chunk.如果您想在本地执行此操作,您可以将error=TRUE添加到特定块。

```{r error=TRUE}
# code that will fail.
```

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

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