```{r, echo=FALSE, results='asis'}# select other variables than 'mpg'x_vars <- setdiff(names(mtcars), 'mpg')# knit the template for eachres <- lapply(x_vars, function(x) { knitr::knit_child('template.Rmd', envir = environment(), quiet = TRUE )})# cat() the knitted output to be included 'asis' cat(unlist(res), sep = '\n')```
Can be combined with knitr::knit_expand()