Separation of R and Rnw files is a type of defeat for literate programming purposes. My own approach is to include code snippets in the appropriate place in the text. If my audience is not interested in the code, I can mark it as
<<foo, echo=FALSE>>= x <- 1:10 @
I can compile the code in the application as
<<appendix-foo, eval=FALSE>>= <<foo>> @
which I admit is a bit of shreds and a tendency to make mistakes (forgotten pieces). One quickly wants to associate a document with supporting material (data sets, useful supporting functions, non-R-scripts) in an R-package, and they are not difficult to create. Building the package automatically creates the pdf and Stangle'd R file that you want. Creating a package can be a slow process, but installing the package does not require the vignettes to be rebuilt, and therefore quickly and conveniently for those to whom you give the package.
To rotate with formatting / text, I use the global option \SweaveOpts{eval=FALSE} .
Martin morgan
source share