Setting document title in Rmarkdown from parameters

后端 未结 3 688
星月不相逢
星月不相逢 2020-12-02 08:33

I\'ve got an Rmarkdown template that works well, and I\'ve parameterized it so I can generate variants of the same report from different data sources. However, I\'d like to

3条回答
  •  悲哀的现实
    2020-12-02 08:51

    This is a more simplified approach to the dynamic title challenge.

    Decouple title from the top declaration like this:

    From this:

    ---
    title: "Sample Title"
    output: pdf_document
    ---
    

    To This:

    ---
    output: pdf_document
    --- 
    
    ```{r}
    title_var <- "Sample Title"
    ```
    
    ---
    title: `r title_var`
    ---
    

    Within the R code chunks, declare title_var. Now the title is held within a variable. Hope this helps!

提交回复
热议问题