2

How can I display a complete Rmarkdown chunk in a knitr Rmd file including the chunk header etc., i.e., treat it as verbatim code which should not be evaluated. What I want an output such as

```{r, results = 'asis'}
some_code
```

I want to have this even after running the file through knitr as I want to show how to set up the chunk in a tutorial. I think I've read a solution somewhere but cannot find it anymore.

All my current attempts have failed. I've tried to wrap the code in another ``` environment and to indent the code by 4 spaces. At best I would also like to have R syntax highlighting, i.e., I would like to use the option r for the code chunk.

Benjamin Hofner
  • 211
  • 1
  • 9

0 Answers0