问题
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