I have a for loop in R, inside of which I want to create R Markdown section headers and print output from R functions such as summary(lm(...)). If I use {r results='asis'} at the start of the code chunk, I can get the section headers to work but the R output won't display properly. If I don't use results='asis' then the R output displays but the section headers won't work. How can I get R-created section headers and R output is the same code chunk, all inside a for loop? There's a complete example R Markdown script and output over at the Stack Overflow post. Thanks!
If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it: