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


i know can done php , other languages, wondering whether following accomplished using knitr:

let's have rmarkdown (.rmd) document 2 heading 1 sections:

# first heading first document lorem ipsum dolor sit amet  # second heading first document plot(object) 
  1. question 1: if open .rmd document, how can create link when parsed document present content whole content first document. example:

    # first heading second document lorem ipsum dolor sit amet  [command goes here insert first document] 

    result be:

    # first heading second document lorem ipsum dolor sit amet  # first heading first document lorem ipsum dolor sit amet  # second heading first document [plot shows here] 
  2. question 2: knitr allow me select , insert selected portions of document 1 document 2? example, heading 1 , content below it, or heading 2 , plot

  1. that chunk option child for, e.g. in second.rmd, can

    ```{r child='first.rmd'} ``` 
  2. that little bit trickier, can call knit_child() manually, e.g.

    ```{r echo=false, results='asis'} # knit first 3 lines of first.rmd cat(knit_child(text = readlines('first.rmd')[1:3]), sep = '\n') ``` 

Comments