3

I'm trying to set echo=FALSE as a default chunk option, but opts_chunk$set(echo = FALSE) doesn't work for notebook output.

Take this .Rmd file, for a regular R Markdown doc

---
title: "Problem with opts_chunk in html_notebook"
output: html_document
---

Set my options in this chunk:
```{r setup}
knitr::opts_chunk$set(echo = FALSE)
```

Chunk 1
```{r echo=FALSE}
cat("Is the code echoed?")
```

Chunk 2
```{r}
cat("Chunk 2. Is the code echoed?")
```

I would expect both the chunks after the setup chunk to execute without echoing the code. With output: html_document, that's what I get:

html_document_good

But if I change the output line to output: html_notebook, I get the following

html_notebook_bad

There's another question here (R notebook: opts_chunk has no effect) with maybe the same issue, but it's not focused on echo = FALSE, and also it has no answers.

Community
  • 1
  • 1
arvi1000
  • 9,393
  • 2
  • 42
  • 52

0 Answers0