Using `r ''` to display full code chunk

I've a Rmarkdown document in which I'd like to show how to write code chunks. I need to display full code chunks (including backticks and chunk options) without executing them.

I saw some examples of this using `r ''` here and there.

Three questions:

  • I couldn't find anything about it. Is there any documentations describing this trick?
  • In the first link, `r ''` comes before the chunk, in the second one, it comes after the chunk head. Are there actual differences between the two?
  • I'd like to do the same with inline chunks but can't make it work. I've tried the same as shown in the first link (see below) but the script errors without explicit message ("execution stopped") when knitting. Any idea how to do that?
```md
`r blah`
```

The new way of doing this is much simpler as we now created the verbatim engine

This is why the trick is no more documented as not needed anymore.

This is documented in the same book 5.6 Verbatim code chunks | R Markdown Cookbook

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.