I don't quite understand some of the terms in the answer above, but the solution relates to defining a custom jersey: hook in the YAML header. For multi-party documents, this allows, for example:
- Have a 'main' or 'root' Rmarkdown file with the
output: markdown_document YAML output: markdown_document - return all child documents from Rmd β md before calling
render , or not if this is a time limit - merge several files (with the option of a child code) into one (for example, for chapters in a report)
- write
output: html_document (or another format) YAML headers for this compilation output "on the fly", adding to the markdown effectively writing a new Rmarkdown file- ... then visualize this Rmarkdown to get the result, deleting the intermediate files in the process, if you want

The code for all of the above ( dumped here ) is described here , a message that I wrote after you recently developed using custom knit: header knit: YAML ( here ).
In the above example, the custom function knit: (i.e. replacing rmarkdown::render ):
(function(inputFile, encoding) { input.dir <- normalizePath(dirname(inputFile)) rmarkdown::render(input = inputFile, encoding = encoding, quiet=TRUE, output_file = paste0(input.dir,'/Workbook-tmp.Rmd')) sink("Workbook-compiled.Rmd") cat(readLines(headerConn <- file("Workbook-header.yaml")), sep="\n") close(headerConn) cat(readLines(rmdConn <- file("Workbook-tmp.Rmd")), sep="\n") close(rmdConn) sink() rmarkdown::render(input = paste0(input.dir,'/Workbook-compiled.Rmd'), encoding = encoding, output_file = paste0(input.dir,'/../Workbook.html')) unlink(paste0(input.dir,'/Workbook-tmp.Rmd')) })
... but everyone is compressed on 1 line!
The rest of the file 'master' / 'root' / 'control' or whatever you want to call takes care of writing the above YAML for the final HTML output that goes through the intermediate Rmarkdown file, and its second chunk code programmatically adds child documents via a call list.files()
```{r include=FALSE} header.input.file <- "Workbook-header.yaml" header.input.dir <- normalizePath(dirname(header.input.file)) fileConn <- file(header.input.file) writeLines(c( "---", paste0('title: "', rmarkdown::metadata$title,'"'), "output:", " html_document:", " toc: true", " toc_depth: 3 # defaults to 3 anyway, but just for ease of modification", " number_sections: TRUE", paste0(" css: ",paste0(header.input.dir,'/../resources/workbook_style.css')), ' pandoc_args: ["--number-offset=1", "--atx-headers"]', "---", sep="\n"), fileConn) close(fileConn) ``` ```{r child = list.files(pattern = 'Notes-.*?\\.md')}
The directory structure will contain a top level folder with
- Final output of
Workbook.html - A
resources containing workbook_style.css - A
documents containing the specified main file "Workbook.Rmd" along with files named "Notes-001.Rmd", "Notes-002.Rmd", etc. (to ensure that files are searched on list.files(pattern = "Notes-.*?\\.Rmd) and therefore makes them children in the correct order when rendering the main Workbook.Rmd file)


For proper file numbering, each component file "Notes-XXX.Rmd" must contain the following YAML style header:
--- title: "March: Doing x, y, and z" knit: (function(inputFile, encoding) { input.dir <- normalizePath(dirname(inputFile)); rmarkdown::render(input = inputFile, encoding = encoding, quiet=TRUE)}) output: md_document: variant: markdown_github pandoc_args: "--atx-headers" --- ```{r echo=FALSE, results='asis', comment=''} cat("##", rmarkdown::metadata$title) ```
The code block at the top of the Rmarkdown document introduces the YAML header as the second-level header in the evaluation. results='asis' indicates returning a text string, not
[1] "A text string"
You would knit each of them before knitting the main file - it would be easier to remove the requirement for rendering all the child documents and just add their preliminary markdown release.
I described all of this from the links above, but I thought that it would be a bad way not to leave the actual code with my answer.
I donβt know how effective a website with a request for an RStudio function can be ... Personally, it was not difficult for me to study the source code of these functions, which, fortunately, are open source , and if there really is something missing, but undocumented, requesting functions with internal processing is probably much more efficient by one of their software developers.
I am not familiar with Sweave, was that what you were aiming for? If I understand correctly, you just want to control the inclusion of documents in a modular way. The child = list.files() operator can take care that: if not through a file push, you can align the list files like child = c("file1.md","file2md") ... and switch this operator so that change them. You can also control the TRUE / FALSE switches with YAML, as a result of which a custom header will include some children, for example,
potentially.absent.variable: TRUE
... above a document with a quiet include=FALSE hiding the fraud of the first fragment:
```{r include=FALSE} !all(!as.logical(rmarkdown::metadata$potentially.absent.variable) # ==> FALSE if potentially.absent.variable is absent # ==> FALSE if anything other than TRUE # ==> TRUE if TRUE checkFor <- function(var) { return !all(!as.logical(rmarkdown::metadata[[var]]) } ``` ```{r child = "Optional_file.md", eval = checkFor(potentially.absent.variable)} ```