Skip to content
alfredas edited this page Aug 22, 2012 · 5 revisions

R Sweave

Rnw files allow you to embed R code within LATEX files using the Sweave LATEX package. For example:

 
 \begin{document}
 <<>>=
 for (i in 1:5) {
  log10(i)
 }
 @
 \end{document}
 

Read more at: http://users.aims.ac.za/~davidw/David_Wakyiku_sweavecs.pdf

Using R Sweave to generate simulation reports

agentspring-R folder contains 3 files that you need to generate a nice pdf report from your simulation:

  1. simulation.R - simulation control and query library
  2. report-pdf.R - query and data manipulation functions that produce charts. You will need to write your own R chart logic here.
  3. report-pdf.Rnw - LATEX Sweave file that assembles the charts into a pdf report. You will need to specify you report layout here.
In order to generate the report one has to compile the Rnw file that would start the simulation, call on the chart creating functions in the report-pdf.R and produce the pdf when the simulation is over.

In order to compile the Rnw file I use RStudio that recognizes the format. But I am sure you can manage with command line pdflatex too.