Re literate programming. A scientist friend of mine likes to build his articles so that the graphs in a TeX are generated from an R script. Makes it easy to change some variables or try different input. sweave is another solution http://www.statistik.lmu.de/~leisch/Sweave/