I\'m writing an RMarkdown document in which I\'d like to re-run some chunks (5 to 9). There\'s no need to display these chunks again, so I considered using
This has been made much easier with the rmarkdown package, which did not exist three years ago. Basically you just turn on "code folding": http://rmarkdown.rstudio.com/html_document_format.html#code_folding. You no longer have to write any JavaScript.
E.g.
---
title: "Habits"
output:
html_document:
code_folding: hide
---