【发布时间】:2018-04-30 00:49:31
【问题描述】:
我想在 R markdown pdf 报告中包含错误消息。这很好用:
---
output: pdf_document
---
This will be knitted and show the error message in the pdf.
```{r, error = TRUE}
stopifnot(2 == 3)
```
但是,如果我尝试使用来自 testthat 的错误的相同方法,我的文档将不再编织。
---
output: pdf_document
---
This will not knit
```{r, error = TRUE}
library(testthat)
expect_equal(2, 3)
```
这是为什么呢?我可以做些什么来包含来自testthat 的expect_something 函数的错误消息而不将它们包装在测试中?
我认为这一定是可能的,因为 Hadley Wickham 在他的书 R 包中包含许多直接来自 expect_something-functions 的错误消息。
这是相关的,但在Include errors in R markdown package vignette 和How to skip error checking at Rmarkdown compiling? 中没有回答
【问题讨论】:
-
在 knitr 中不支持的测试。见github.com/yihui/knitr/issues/1413
标签: r knitr r-markdown testthat