html_notebook ignores global chunk options

一笑奈何 提交于 2019-12-10 17:32:58

问题


Is there a way to use global chunk options in html_notebooks?

This html_document only shows the title (as desired in this MWE):

---
title: "Test"
output: 
 html_document
---

```{r setup, echo=FALSE}     
library(knitr)
opts_chunk$set(echo=FALSE, results='hide', fig.keep='none')

```

```{r}        
1+1
plot(1:5, 1:5)
```

However, the very same document as an html_notebook shows all code chunks and output (the global chunk options are ignored):

---
title: "Test"
output: 
 html_notebook
---

```{r setup, echo=FALSE}     
library(knitr)
opts_chunk$set(echo=FALSE, results='hide', fig.keep='none')

```

```{r}        
1+1
plot(1:5, 1:5)
```

I do not think this is intended, as I can supply the chunk options to the chunk directly and get the desired result (only the title):

---
title: "Test"
output: 
 html_notebook
---

```{r setup, echo=FALSE}     
library(knitr)

```

```{r echo=FALSE, results='hide',  fig.keep='none'}        
1+1
plot(1:5, 1:5)
```

来源:https://stackoverflow.com/questions/41911487/html-notebook-ignores-global-chunk-options

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!