Use loop to generate section of text in rmarkdown
<p>I need to produce a report that is composed of several sections, all sections look similar, with only some differences in data. The number of sections is also dependent on the data. What I ultimately want to have is something like this:</p>

<pre><code>```{r}
  section_names = c("A","B","C")
  section_data = c(13,14,16)
```

# some looping mechanism here with variable i

This is section `r section_names[i]`

This section's data is `r section_data[i]`

#more things go here for the section

#end of loop should go here
</code></pre>

<p>The result should be a single html/document with all the sections one after the other.</p>

<p>Can you point me to a way for producing such an Rmd file with the loop?</p>

<p>Ideally I would have hoped to see something like in PHP:</p>

<pre><code>&lt;$php for(i=0;i&lt;10;i++) { ?&gt;
   ## some html template + code chunks here
&lt;$php } ?&gt;
</code></pre>