Sweave control of chuk output

时间:2015-06-30 13:57:10

标签: r sweave

I'm using Sweave to make a report in R-Studio, and I have the problem, that my teacher will only accept reports, where the code is placed in an Appendix. This means that I need to control the position of the chunk outputs (graphs).

Is this possible in Sweave?

Regards,

Jens

1 个答案:

答案 0 :(得分:0)

这将返回代码中的所有内容。假设您的文件名为test.Rnw

,请使用\ usepackage {fancyvrb}和\ VerbatimInput {test.Rnw}
\documentclass{article}
\usepackage{fancyvrb}

\begin{document}
\SweaveOpts{concordance=TRUE}

<<my_code_chunk>>=
2+2
@

\section{Appendix}
\VerbatimInput{test.Rnw}

\end{document}

这是另一个例子

\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
<<my_code_chunk>>=
2+2
@
\section{Appendix}

<<>>=
<<my_code_chunk>>
@

\end{document}