I am new to Sweave/Tex and would like to keep my R code out of the Sweave file as much as possible. Ideally, I would like to reference my R files within Sweave's .Rnw file and then have Sweave read it directly.
An example might be something like this:
\begin{document}
\title{Project}
\author{Author}
\date {\today}
<<>>=
**Reference to file: projectcode.R**
@
\begin{figure}[H]
<<fig=TRUE,echo=FALSE,png=TRUE,pdf=FALSE,eps=FALSE>>=
ggplot(df, aes(x, y)) + geom_line()
@
\end{figure}
\end{document}
Thanks