Below is the RMarkdown solution analogous to https://github.com/yihui/knitr-examples/blob/master/020-for-loop.Rnw, using knit_child()
. As my solution, it requires two files, but it is much more clear.
mainfile.Rmd:
```{r, echo=FALSE}
J <- length(lSlopes)
```
```{r runall, include=FALSE}
out <- NULL
for (i in 1:J) {
out <- c(out, knit_child('stepfile.Rmd'))
}
```
`r paste(out, collapse = '\n')`
Nice!
stepfile.Rmd:
```{r, echo=FALSE}
lSlopes[[i]]
```