Run the code in a specified chunk
We can specify a chunk label and use this function to evaluate the code in this chunk. It is an alternative to the chunk reference in Sweave.
run_chunk(label, envir = parent.frame())
- the chunk label
- the environment in which to evaluate the code
The difference between this type of chunk reference and
the chunk option
ref.label is that the latter can
only be used for a chunk so that it has exactly the same
code as the reference chunk, whereas this function makes
it possible to collect several little chunks and run them
inside another big chunk.
- Values returned by the code in the chunk.
Recursion (must be finite, of course) of reference is allowed, e.g. we may run the code of chunk2 in chunk1, and chunk2 also contains a reference to chunk3, then if we run chunk1, both the code in chunk2 and chunk3 will be evaluated.
# see http://yihui.name/knitr/demo/reference/