When you use knit_expand
it appears that the inclusion of the Rmd is done on the first pass, and then the complete document evaluated. This means that a Rmd block referenced in loop with knit_expand
will only evaluate changing variables at their last value.
This can be worked around by passing the literal value of the variable at the time of the knit_expand
with {{var}}
syntax.
This is documented in the knitr_expand docs, but less clear (to an R noob like me) for embedded documents rather than strings.