Let's suppose your child document is named child.Rmd
and has the following contents.
```{r pressure, echo=FALSE, dev='pdf'}
plot(pressure)
```
Run
knitr::knit("child.Rmd")
and you get figure/pressure-1.pdf
and child.md
. Then run
rmarkdown::pandoc_convert("child.md", to = "latex", output = "child.tex")
Resulting child.tex
file only contains \begin{figure} ~~ \end{figure}
block inside. I hope this is the desired result.
If you don't have a strong reason to use RMarkdown, I'd recommend R Sweave; knitr supports child documents
UPDATE You didn't have to remove YAML header from your Rmd file; the above knitr::knit
and rmarkdown::pandoc_convert
combination ignores the YAML header. Take a look at this gist. Run run_this.R
script and child.Rmd
will be converted to child.tex
. You can of course render this Rmd file to html normally.