knit_child

0th

Percentile

Knit a child document

This function knits a child document and returns a character string to input the result into the main document. It is designed to be used in the chunk option child and serves as the alternative to the SweaveInput command in Sweave.

Usage
knit_child(..., eval = TRUE)
Arguments
...
arguments passed to knit
eval
logical: whether to evaluate the child document
Details

For LaTeX output, the command used to input the child document (usually input or include) is from the package option child.command (opts_knit$get('child.command')). For other types of output, the content of the compiled child document is returned.

When we call purl() to extract R code, the code in the child document is extracted and saved into an R script.

The path of the child document is relative to the parent document.

Value

  • A character string of the form child-doc.tex or source("child-doc.R"), depending on the argument tangle passed in. When concordance is turned on or the output format is not LaTeX, the content of the compiled child document is returned as a character string so it can be written back to the main document directly.

Note

This function is not supposed be called directly like knit(); instead it must be placed in a parent document to let knit() call it indirectly.

References

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

Aliases
  • knit_child
Examples
## you can write \\Sexpr{knit_child('child-doc.Rnw')} in an Rnw file
## 'main.Rnw' to input child-doc.tex in main.tex

## comment out the child doc by \\Sexpr{knit_child('child-doc.Rnw', eval =
## FALSE)}

## use \\include: opts_knit$set(child.command = 'include')
Documentation reproduced from package knitr, version 0.9, License: GPL

Community examples

Looks like there are no examples yet.