3

I'm using Markdown through RStudio and knitr to built a R exercises sheet for a course I'll give soon. I want to hide the answer of the exercises like we can do here on stackoverflow. example:

This text his hidden

To see the box before, you have to put your cursor over it. This is easily done here (on stackoverflow) by adding >! before what your want to hide.

How to I hide text like that in RMarkdown using knitr in RStudio? I would like to hide the entire code block (the script and the result)

Example of what I want to produce with knitr:

Question 1)

Evaluate the mean of this vector:

vec1 <- 1:5

Answer:

mean(vec1) ## 3

Martin Schmelzer
  • 23,283
  • 6
  • 73
  • 98
Bastien
  • 3,007
  • 20
  • 38
  • 4
    Perhaps [this](http://stackoverflow.com/questions/37755037/how-to-add-code-folding-to-output-chunks-in-rmarkdown-html-documents) helps – akrun Apr 27 '17 at 12:00
  • Thanks @akrun, It's not exactly what I was looking for, but it does the trick. It may even be better considering it forces people to click on the box, preventing accidental look. – Bastien Apr 27 '17 at 12:51

0 Answers0