Skip to content
Prev 172235 / 398506 Next

Converting R to Sweave (Rnw)

Rainer M Krug-6 wrote:
This seems like trying to put the cart before the horse to my mind.

A .Rnw is a hybrid of LaTeX and R code the later is delineated from the
former by being encapsulated by the (<<name>>= ... @) tags which also define
whether the results and/or images should be included in the LaTeX output.

If you always want to use Sweave to document your code thats you're
prerogative, but its really designed for writing a report with the R-code
embedded, some of that code (reading in files etc.) is not relevant to the
code so is suppressed, whilst others the output of the commands is required
(and you duly write the tags around the R code to show the relevant output).

If all you want to do is comment you're code, then I see nothing wrong or
hard about using the '#' delimiter which comments out all text that follows
its insertion in your .R file.  Personally when I write Sweave documents I
include comments in the R section of the files using this delimiter.

Neil