Sweave and Xtable combining R analysis and LaTeX typesetting Lars Nilse Tübingen University
separate R analysis and LaTeX typeseting *.R raw data 16 ● 14 ● ● 12 ● 10 y 8 ● 6 ● 4 ● 5 10 15 20 25 x analysed data (tables, plots)
separate R analysis and LaTeX typeseting *.R raw data 16 ● 14 ● ● 12 ● 10 y 8 16 ! ● 14 ! ! 6 ● 12 ! 10 4 y ● 8 ! 6 ! 5 10 15 20 25 4 *.tex ! x 5 10 15 20 25 x analysed data Figure 1: simple scatter plot Data Analysis (tables, plots) The data of file data20110113.csv are listed in Tab. 1 and plotted in Fig. 1. The average x is 8.8571. V1 V2 1 1 6 2 2 7 3 3 3 4 6 12 5 9 14 6 16 14 7 25 16 Table 1: data from file final report
Sweave script 16 ! 14 ! ! 12 ! 10 y 8 ! 6 ! 4 ! *.Snw 5 10 15 20 25 x Figure 1: simple scatter plot Data Analysis The data of file data20110113.csv are listed in Tab. 1 and plotted in Fig. 1. The average x is 8.8571. V1 V2 1 1 6 2 2 7 3 3 3 4 6 12 raw data 5 9 14 6 16 14 7 25 16 Table 1: data from file final report
*.Snw = *.tex with embedded *.R
<< ... >> some R code @
\Sexpr{ some R expression }
generating tables using Xtable
embedding plots
16 ! 14 ! ! 12 ! 10 y 8 ! 6 ! 4 ! 5 10 15 20 25 x Figure 1: simple scatter plot Data Analysis The data of file data20110113.csv are listed in Tab. 1 and plotted in Fig. 1. The average x is 8.8571. V1 V2 1 1 6 2 2 7 3 3 3 4 6 12 5 9 14 6 16 14 7 25 16 Table 1: data from file
snw2pdf.sh
snw2pdf.sh data20110113.csv template.Snw
snw2pdf.sh data20110113.csv template.Snw data20110113.Snw
snw2pdf.sh data20110113.csv template.Snw data20110113.Snw data20110113.tex
snw2pdf.sh data20110113.csv template.Snw data20110113.Snw data20110113.tex data20100113.pdf
Sweave links • Sweave homepage http://www.stat.uni-muenchen.de/~leisch/Sweave/ • Sweave example http://bit.ly/hkkyyb
Recommend
More recommend