Optimizing R Markdown workflow - reusing R Markdown chunks with parameters?

Hmmm. I think you did, but the problem is I don't use child documents, so I can't follow you very well. Still, could parametrized reports help in your case? Now, if you don't share a minimal reproducible example I cannot really understand what's going on (and I cannot test solutions). However, one limit of child documents is that they all share the same enviroment as the main document, unless you do something very special.
To pass parameters to child documents, all sharing a common environment:

To call multiple times the same child document, but each time with different arguments in a different environment:

Note that unfortunately the example is for .Rw (run Sweave) documents, rather than for .Rmd (R Markdown) documents, but knit_child() should work the same way for .Rmd files:

1 Like