I want to iterate over a list of result-sets in my R markdown file. When I produce the output I want to include some text like headers with the name of the result set.
An alternative solution with pander:
<% for (res in names(results)) { %>
### Results for: <%= res %>
<%=
plot(results[[res]]$x, results[[res]]$y)
%>
<% } %>
And just Pandoc.brew this in one run to get what you were up to:
> Pandoc.brew('doc.brew')
### Results for: result1

### Results for: result2

Or generate HTML/docx/etc. in one run:
> Pandoc.brew('doc.brew', output = tempfile(), convert = 'html')
> Pandoc.brew('doc.brew', output = tempfile(), convert = 'docx')