【问题标题】:How do you embed R markdown code within R Markdown?你如何在 R Markdown 中嵌入 R Markdown 代码?
【发布时间】:2020-08-10 00:47:55
【问题描述】:

我正在教学生如何创建/编辑 R markdown 文件。所以我想在我的 R markdown 文件中有一个 R markdown 模板。下面是一个例子:

---
title: "file_check"
author: "James"
date: "8/7/2020"
output: html_document
---

Learn by copying this into blank .Rmd file:

---
title: "Template"
author: "Your Name"
date: "Specify Date"
output: html_document
---

This is how you plot 
```{r}
plot(1:10)
```

当我运行它时,我显然会遇到错误,但我知道必须有一种快速/有效的方法来执行此操作,因为 R markdown 网站具有此功能。

【问题讨论】:

  • 你遇到了什么错误?我运行你的代码没有任何问题

标签: r r-markdown


【解决方案1】:

您可以使用 text 块:

---
title: "file_check"
author: "James"
date: "8/7/2020"
output: html_document
---

Learn by copying this into blank .Rmd file:
```{text} 
--- 
title: "Template" 
author: "Your Name"
date: "Specify Date"
output: html_document
---
```

This is how you plot 
```{r}
plot(1:10)
```

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-27
    • 2018-05-07
    • 2017-10-06
    • 1970-01-01
    • 1970-01-01
    • 2016-10-17
    相关资源
    最近更新 更多