---
: "Child docs (RMarkdown)"
title: html_document
output---
- RMarkdown verion
Test quarto document using child docs
```{r, include=FALSE}
library(knitr)
```
```{r, results='asis', echo=FALSE}
a <- knitr::knit_child('child_doc_01.Rmd', quiet=T)
cat(a, sep='\n')
```
Quarto is the new publishing system from RStudio based on Pandoc. It’s a powerful tool for publising from R, Python and Julia, working in a very similar fashion to RMarkdown.
There are several great blog posts already highlighting features of Quarto and thoughts on changing from RMarkdown to Quarto.
Recently, I’ve been building up dynamic documents using child documents. The aim is to identify the parts of a document (report) required and compile them into a main report as child documents. I’ve also started to use Quarto, but can Quarto build a document from a selection of child docs? The answer is ‘yes’.
RMarkdown Version
knitr Child documents are a great way to manage long reports. They provide a method to break a document into sections and knit the sections together upon rendering. Below we have a main Rmd document and a child Rmd document. When rendered, the child document is incorporated into the main document.
Main Document
Child Document 1 (child_doc_01.Rmd)
---
: "my child 01"
tag: "child doc 01"
title---
## Child Doc 1
#1 - this is an RMarkdown child document Child document
Output
Quarto Version
Quarto child documents can be knitted in the same way as RMarkdown documents, using knitr::knit_child. In fact Quarto and RMarkdown child documents can be mixed as shown below.
Main Document
---
: "Child docs"
title: html
format:
execute: false
echo-contained: true
self---
::knit_child
Quarto child documents are compatible with knitr
```{r}
#| include: false
library(knitr)
```
```{r, results='asis'}
a <- knitr::knit_child('child_doc_01.Rmd', quiet=T)
cat(a, sep="\n")
```
```{r, results='asis'}
a <- knitr::knit_child('child_doc_02.qmd', quiet=T)
cat(a, sep="\n")
```
Child Document 2 (child_doc_02.qmd)
---
: "Untitled"
title: html
format---
## Child Doc 2
#2 - this is a quarto child document running {ojs} cell
Child document
```{r}
ojs_define(data = mtcars)
```
```{ojs}
Plot.plot({
marks: [
Plot.dot(transpose(data),
{x: "mpg", y: "hp", stroke: "cyl"}
)
]}
)
```