You probably know that you can include a child document in a knitr document (such as R Markdown) via the chunk option child. If you do not, you may see Section 16.4 of the R Markdown Cookbook.

You may also know that you can convert an R script to R Markdown via the function knitr::spin(). Again, if you do not, you may read Section 3.3 of the book.

Then the question is, when you render an R Markdown …