knitr (version 0.4)

knit_env: The environment in which a code chunk is evaluated

Description

This function makes the environment of a code chunk accessible inside a chunk.

Usage

knit_env()

Arguments

Details

In some special cases, we need access to the environment of the current chunk; a typical example is when we use source() in a cached chunk, we have to make sure the script is executed in the correct environment (should not use the default local environment). See references for an example.

References

http://yihui.name/knitr/demo/cache/