[R] Sweave and echoing R comments
Charles H. Franklin
chfrankl at wisc.edu
Sun Jun 20 20:57:59 CEST 2004
Is there any way to echo comments from an R source file into an
SWeave->LaTeX document?
Example:
# Npop is population total
# Npoph0..Npoph2 are stratum totals
# Npoph is vector of stratum totals
Npop<-sum(to2000)
Npoph0<-sum(to2000[bg==0])
Npoph1<-sum(to2000[bg==1])
Npoph2<-sum(to2000[bg==2])
Npoph<-c(Npoph0,Npoph1,Npoph2)
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.
Thanks.
Charles
--
Charles H. Franklin
Professor, Political Science
University of Wisconsin, Madison
608-263-2022
franklin at polisci.wisc.edu
chfrankl at wisc.edu
More information about the R-help
mailing list