I am generating an HTML report using Rmarkdown in which I want the user to have an option of looking at code (when they want by using a toggle show/hide code) before each section or figure.
I am wondering if there is an option to do so globally and individually for each code chunk.
I have looked at some previous solutions using javascript, but I am not familiar with the language. I was hoping there is an option I can choose within Rmarkdown.
Previous approaches using javascript are shown here and here, but I am not sure how to include these in my Rmarkdown file. I have tried the following, but it didn't work
<script src="toggleR.js"></script>
```{r}
summary(cars)
```
A working example in Rmarkdown would be extremely helpful!!
Thanks
I am generating an HTML report using Rmarkdown in which I want the user to have an option of looking at code (when they want by using a toggle show/hide code) before each section or figure.
I am wondering if there is an option to do so globally and individually for each code chunk.
I have looked at some previous solutions using javascript, but I am not familiar with the language. I was hoping there is an option I can choose within Rmarkdown.
Previous approaches using javascript are shown here and here, but I am not sure how to include these in my Rmarkdown file. I have tried the following, but it didn't work
<script src="toggleR.js"></script>
```{r}
summary(cars)
```
A working example in Rmarkdown would be extremely helpful!!
Thanks
Share Improve this question edited May 23, 2017 at 12:08 CommunityBot 11 silver badge asked Aug 18, 2015 at 15:36 SatyaSatya 1,8001 gold badge16 silver badges40 bronze badges 2- The accepted answer for your second link should give you what you want. For output chunks take a look at this: stackoverflow./questions/37755037/… – Martin Schmelzer Commented Jun 16, 2016 at 7:41
- Possible duplicate of How to hide code in RMarkdown, with option to see it – Martin Schmelzer Commented Jun 16, 2016 at 14:12
1 Answer
Reset to default 4From the answer to a similar question by Yihue -this functionality has now been added as code folding. See more at http://rmarkdown.rstudio./html_document_format.html