Search

Monday, February 13, 2006

Sweave introduction

Sweave is a package that comes with R, and can be used to interleave LaTeX and R code. Here's how I use it:

(I'm assuming you've got R installed on your machine.)

1. Download the bash script Sweave.sh from here. Install it in your bin directory, and be sure to change the first line to reflect the location of your bash.

2. Download the file Sweave-test-1.Rnw into a temporary directory.

3. cd to that directory and now run the script on this file:
Sweave.sh Sweave-test-1.Rnw. If all goes well, you have a .tex file Sweave-test-1.tex.

4. Compile the .tex file in whatever way is usual for you. The Sweave FAQ is a must-read.

No comments: