在 Markdown 文件中渲染 rMarkdown 文件 [英] Rendering rMarkdown File in a Markdown file

查看:76
本文介绍了在 Markdown 文件中渲染 rMarkdown 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我要在 rMarkdown 文件中使用 rmarkdown::render(myFile).如何让第一个 rMarkdown 文件显示渲染的第二个 rMarkdown 文件?目前我有:

If I were to use rmarkdown::render(myFile) within an rMarkdown file. How would I get the first rMarkdown file to display the rendered second rMarkdown file? At present I've got:

{r other, results="asis"}myFile <- "SecondFile.Rmd"rmarkdown::render(myFile)但这只是输出在编织降价时生成的控制台文本,而显然我想要编织的 HTML 结果.

{r other, results="asis"} myFile <- "SecondFile.Rmd" rmarkdown::render(myFile) But this is just outputting the console text generated while the markdown is being knit, whereas obviously I want the HTML result of the knit.

推荐答案

好吧,经过一番摆弄后,我能想出的最佳答案是这个,但如果有更多问题,我很高兴有人纠正我正确"的方式.

Okay, after some fiddling the best answer I can come up with is this, but I'm more than happy for someone to correct me if there is a more 'proper' way.

```{r setup}
library(htmltools)
```
##Title

```{r generate, include=FALSE}
rmarkdown::render(myFile)
```

```{r print}
includeHTML(myFile)
```

这篇关于在 Markdown 文件中渲染 rMarkdown 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆