【问题标题】:Referencing master file with rmarkdown (knitr)使用 rmarkdown (knitr) 引用主文件
【发布时间】:2015-03-08 14:02:16
【问题描述】:

我有一个包含子文件的父文件,当我按 Cmd+shift+k(我正在使用 rstudio)时,我想编译父文件。我知道在乳胶中,您可以通过在子文件顶部编写一行代码来引用主文件。我想知道你是否可以用 rmarkdown 做类似的事情?

【问题讨论】:

    标签: r knitr r-markdown


    【解决方案1】:

    在 R Markdown 中它是这样工作的:

    ---
    title: "parent"
    output: pdf_document
    ---
    
    This is the title page
    
    ```{r child='child1.Rmd'}
    ```
    
    ```{r child='child2.Rmd'}
    ```
    

    在此示例中,.Rmd 子文件位于同一文件夹中。

    您不需要在子.Rmd 中指定 YAML 标头

    【讨论】:

      【解决方案2】:

      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}
      

      【讨论】:

      • 我尝试在使用 set_parent 的地方添加一个夹头,但它似乎不起作用。使用 rmarkdown 时是否有效?
      猜你喜欢
      • 2016-05-29
      • 2015-12-02
      • 2016-10-06
      • 1970-01-01
      • 2015-07-03
      • 1970-01-01
      • 2016-12-16
      • 2021-02-06
      • 2015-07-06
      相关资源
      最近更新 更多