The optimal way to do sweave

October 16, 2009

(This article was first published on Shige's Research Blog, and kindly contributed to R-bloggers)

The optimal way to do sweave may be to have a master file in LaTeX, and a separate Rnw file contains all the computations, figures, and tables. That way, it is easy to compile the LaTeX as the writing goes on without the hassle of carrying out the computations (especially when some of them are heavy) every time.

When the computations are finished, one can simply include the generated LaTeX output in the master LaTeX file to get the complete manuscript. Here are the files:

  1. master.tex: the master LaTeX file that contains text materials of a paper;
  2. tables.Rnw: the sweave file for creating all the tables;
  3. tables.tex: the LaTeX output file that can be included in the master file;
  4. figure.Rnw: the sweave file for creating all the figures;
  5. figure.tex: the LaTeX output file that can be included in the master file;
  6. driver.tex: a simple LaTeX driver to view the tables and figures before including them into the master LaTeX file.

To leave a comment for the author, please follow the link and comment on their blog: Shige's Research Blog. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , ,

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)