Rmarkdown 可以有一个非工作代码,编织 html 输出显示错误和警告

Can Rmarkdown having a non working code, knit html output showing the errors and warnings

假设我在 R 中有 not working 代码,即我 运行 该代码并收到一些错误和警告,我想分享显示错误和警告的代码和输出,通过R markdown与第三人称。

如果我在 r 代码块中有错误,是否可以编写 R markdown?如果是,那么它是否会向我显示 html 输出中出现的错误和警告? 目标是与非工作代码共享 html output 显示错误和所有内容。

非常感谢对此的任何帮助。谢谢

是,使用knitr::opts_chunk$set(error = TRUE)

这里是完整的降价:

---
title: "Untitled"
date: "September 21, 2016"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, error = TRUE)
```

## R Markdown

Here is my error

```{r}
1 + 1
1 + "a"
```

输出: