insert portions of a markdown document inside another markdown document using knitr

后端 未结 1 1865
迷失自我
迷失自我 2020-12-13 15:29

I know this can be done with php and other languages, but was wondering whether the following could be accomplished using knitr:

Let\'s say I have an Rmarkdown (.rmd

相关标签:
1条回答
  • 2020-12-13 15:45
    1. that is what the chunk option child is for, e.g. in second.Rmd, you can

      ```{r child='first.Rmd'}
      ```
      
    2. that is a little bit trickier, but you can call knit_child() manually, e.g.

      ```{r echo=FALSE, results='asis'}
      # knit the first three lines of first.Rmd
      cat(knit_child(text = readLines('first.Rmd')[1:3]), sep = '\n')
      ```
      
    0 讨论(0)
提交回复
热议问题