Created
May 13, 2014 23:30
-
-
Save casallas/a44c4c55ec5f0db03361 to your computer and use it in GitHub Desktop.
knitr include (not input) child
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This chunk below is from the child document. | |
<<set-parent, echo=FALSE, cache=FALSE>>= | |
if(!exists("master_mode")) master_mode <- F | |
if(!master_mode) | |
knitr::set_parent('knitr-include.Rnw') | |
@ | |
<<test-child, out.width='2in', fig.show='asis'>>= | |
1+1 | |
rnorm(5) | |
plot(1) | |
boxplot(1:10) | |
str(mtcars) | |
@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\begin{document} | |
<<test-main>>= | |
options(width = 60) | |
summary(iris) | |
@ | |
Let's see how to work with child documents in knitr. Below we include | |
the file \textsf{knitr-include-child.Rnw}: | |
<<child-demo, echo=FALSE, warning=FALSE>>= | |
master_mode <- T | |
knitr::knit("knitr-include-child.Rnw", "knitr-include-child.tex") | |
#cat("\\input{knitr-include-child}")# Add results='asis' to the chunk options | |
@ | |
\input{knitr-include-child} | |
Done! | |
Modified from: http://yihui.name/knitr/demo/child/ | |
\end{document} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment