I keep R and Rnw files separate, then load the R data/plots with load(\"file.R\")
in the first Sweave chunk. Is there a way that I can print the sourced R file
I usually solve this by:
\begin{appendix}
\section{Appendix A}
\subsection{R session information}
<>=
toLatex(sessionInfo())
@
\subsection{The simulation's source code}
<>=
Stangle(file.path("Projectpath","RnwFile.Rnw"))
SourceCode <- readLines(file.path("Projectpath","Codefile.R"))
writeLines(SourceCode)
@
\end{appendix}
Using this you have to think of a maximum numbers of characters per line.