Description Usage Arguments Value
Includes a child document (as raw markdown text) where called. The parameters
from the parent and child will be collected as specified by param
and made
available for use by the child. The parent document parameters are unchanged.
The child runs in its own environment as if it was a function,
but one or more objects can be passed back from the child (independent of
parameter) for use in the parent environment (where the child was called).
This parent environment can be specified if desired, controlling both what
is seen by the child and capturing returned variables separate from the
parent documents "global" scope.
1 2 3 4 5 6 7 | includeChild(
file,
param = "parent",
import = "RET_VAL",
envir = parent.frame(),
...
)
|
file |
The child file to knit. Path is relative to the parent. |
param |
What is visible to the child document as the
|
import |
A variable name or names used for communicating between the child. Must be a character vector. After child inclusion, these variables will exist and will have the value it was assigned in the child, if any. Otherwise it will have the value it had before the child was knitted. Note that these can be function names, allowing importing child-defined functions into the parent scope as well as data. |
envir |
The parent environment to the environment the child runs in.
By default this is just where this function is called, its parent.frame().
Anything defined in this environment (or its parents) will be visible to
the child as normal, except for the modified |
... |
Other parameters passed to knitr::knit_child and hence on to knitr::knit |
Returns the knitted child as markdown text to be processed here as
the parent knit continues. It is text but with the the class knit_asis
.
This avoids the need to have this function called in an R code chunk using
the result= "asis"
option. It will be interpreted as any other literal
markdown text would be if included where called, either from inside a chunk
(with the chunk setting include=TRUE
), or inline if called outside a
chunk.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.