【发布时间】:2015-03-08 14:02:16
【问题描述】:
我有一个包含子文件的父文件,当我按 Cmd+shift+k(我正在使用 rstudio)时,我想编译父文件。我知道在乳胶中,您可以通过在子文件顶部编写一行代码来引用主文件。我想知道你是否可以用 rmarkdown 做类似的事情?
【问题讨论】:
标签: r knitr r-markdown
我有一个包含子文件的父文件,当我按 Cmd+shift+k(我正在使用 rstudio)时,我想编译父文件。我知道在乳胶中,您可以通过在子文件顶部编写一行代码来引用主文件。我想知道你是否可以用 rmarkdown 做类似的事情?
【问题讨论】:
标签: r knitr r-markdown
在 R Markdown 中它是这样工作的:
---
title: "parent"
output: pdf_document
---
This is the title page
```{r child='child1.Rmd'}
```
```{r child='child2.Rmd'}
```
在此示例中,.Rmd 子文件位于同一文件夹中。
您不需要在子.Rmd 中指定 YAML 标头
【讨论】:
knitr /demo/child/ page 概述了如何执行此操作。
如果信息不够丰富,您可以查看论文模板 repo 的 README 中的 knitr section。
最后,您可以在https://github.com/stevenpollack/masters_thesis/blob/master/masters_thesis.Rnw 中看到正在运行的父子模型。该链接的精简版将是:
\documentclass[masters]{ucbthesis}
\begin{document}
<<abstract, child='abstract.Rnw'>>=
@
<<introduction, child='introduction.Rnw'>>=
@
<<adaboostToBoost, child='boosting_methodology.Rnw'>>=
@
<<boostrImplementation, child='boostr_implementation.Rnw'>>=
@
<<discussion, child='summary_and_future_work.Rnw'>>=
@
\end{document}
【讨论】: