r - Preserve markdown in chunked file for knitr -


i have r script called rundataanalysis.r, in have call long analysis file actualanalysis.r.

i want generate report knitr (i'm not using rstudio).

so followed good advice , did following:

i have ## @knitr runmostanalyses @ top of long analysis file.

i have these lines in rundataanalysis.r file:

--- output: html_document:          toc: true ---  ```{r echo=false} read_chunk('pathtofile/actualanalysis.r') ```  ```{r first} <<runmostanalyses>> ``` 

finally, run , report calling rmarkdown::render('rundataanalysis.r'). works part doesn't preserve markdown indicated in sourced file (at least not in same format works rmarkdown). example, have different title levels #' #, #' ## , #' ###. gets copied verbatim in report file , not interpreted titles (and included in table of contents). couldn't find relevant option in chunk options.

is syntax different or doing wrong when evaluating chunk?

if import rmd rmd files, can use 1 of solutions described here: either using chunk parameter child

```{r, child = 'pathtofile/actualanalysis.r'} ``` 

or using function knit_child (which returns converted document string) chunk parameter results set 'asis':

```{r echo=false, results='asis'}    cat(knit_child(text = readlines('pathtofile/actualanalysis.rmd', quiet = true))  ``` 

if imported files formatted r scripts processed spin, same should work after replacing knit_child spin_child.

if parent document such formatted r script processed spin (not rmd, in example), import child documents (formatted spin) using double curly braces, described in spin_child documentation:

{{ spin_child('pathtofile/actualanalysis.r') }} 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -