[R] Sweave and echoing R comments
Frank E Harrell Jr
f.harrell at vanderbilt.edu
Sun Jun 20 22:34:50 CEST 2004
Charles H. Franklin wrote:
> Is there any way to echo comments from an R source file into an
> SWeave->LaTeX document?
> # Npop is population total
> # Npoph0..Npoph2 are stratum totals
> # Npoph is vector of stratum totals
> In the final LaTeX document, I'd like the comments to be echoed so
> readers other than me have guidance about variable names etc.
> I suppose advocates of literate programming might argue that if the
> comment is important it should be in the body of the .snw file, not
> merely as R comments. Still... it seems easier to use brief comments in
> the code itself and more explanatory text in the body of the document.
> Searches of "Sweave" and "comment" in the list and documentation didn't
> turn up anything about echoing comments in either R or Sweave.
I agree that it would be nice to see comments in the output. I hope
that Fritz Leisch will consider adding a hook that is a user-provided R
function that take vectors of character strings representing a chunk of
code and generating any desired LaTeX markup for pretty printing of the
code. The function would return character vectors in LaTeX format. I
like comments to appear in a smaller font, and for certain character
translations, such as <- being replaced with a left arrow.
Frank E Harrell Jr Professor and Chair School of Medicine
Department of Biostatistics Vanderbilt University
More information about the R-help