How to show RMarkdown-Code in a RMarkdown-File
When you’re writing about RMarkdown using RMarkdown you may run into trouble when the RMarkdown parser parses the code you want to be simply embedded in your site.
Let’s say you want to show a simple Rmd-file like this
|
|
If you put the above code into your RMarkdown-page (like this blogdown article) the code-chunks (lines 8-10 and 14-16) will be run by R and the output is put into your article.
So you have to mask it.
First you have to surround the whole code with
|
|
Every R code chunk must be preceded with `r ''`
.
So you get
|
|
Another way is to include the code using readLines()
.
|
|