Using echo = {number} removes code toggles in R Notebooks

68 Views Asked by At

So if I have some code, such as:

---
title: "Data Exploration"
output: html_notebook
---

```{r, echo = 2}
data("mtcars")
summary(mtcars$mpg)
```

then I would expect only the 2nd line, i.e. summary(mtcars$mpg) to show in my previewed document. But what it actually does is remove all code from my previewed document and removes the show/hide code toggle button. Any idea how I can show certain lines whilst keeping the toggle button?

1

There are 1 best solutions below

4
On

I would have added this as a comment, but I do not have that capability yet. This seems like it might be a bug. It works fine in the other document types. If you need to use a notebook the not so elegant work around would be to just use two chunks.