This is because only the last printed content show in a knitr unless you really knit the content of the chunk. knit_child()
is about that.
I would look at resource in this other topic
Basically using a R Markdown child document as template is what would be the easiest
You'll find more on this site about how to programatically create content.
Create a function that would fill your template, and run knit_child()
on it to integrate the result in your main document.
Look at the cookbook to understand with some recipies how this all works.