本文介绍了如何在R Markdown文档中嵌入和转义R Markdown代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编写有关R Markdown语法的备忘录,因此,我想在文档的输出中包含R Markdown代码和.
I'm trying to write a memo on R Markdown syntax and as such I'd like to include in the document's output the R Markdown code and the output.
要清楚,我希望输出看起来像:
To be clear, I'd like the output to look something like:
~~~~~~~~~~~~~~~~~
在文档中包括以下代码块:
~~~~~~~~~~~~~~~~~~
Including the following code chunk in the document:
```{r, eval=FALSE}
summary(cars)
```
将产生以下输出:
summary(cars)
~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~
我无法逃避```
和.
推荐答案
也许您对此进行了评估:
Maybe if you evaluate this:
```{r comment=NA}
cat("```{r, eval=FALSE}\nsummary(cars)\n```")
```
这篇关于如何在R Markdown文档中嵌入和转义R Markdown代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!