You are not supposed to use knit_child()
interactively. It was designed to be called inside knit()
.
As you have noted, knit_child()
in the latest version of knitr
returns the content of the child document if you do not provide the second argument. By explicitly providing the second argument sprintf('test-template-%d.tex', i)
, you mean "please write the output to this file and return the filename".
To fix the problem, you need to remove the second argument:
<<run-all, include=FALSE>>=
out = NULL
for (i in 1:10) {
out = c(out, knit_child('test.rnw'))
}
@
\Sexpr{paste(out, collapse = '\n')}