LaTeX and Sweave
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
LaTeX is a typesetting language that is known for its beautiful mathematical formulas. It is similar to HTML in that you write your document in plain text and process (or compile) it to create a postscript or PDF file. You will need to download a LaTeX processor for your platform. On Windows, TeXnicCenter (http://www.texniccenter.org/) is very good and on Mac TeXShop (http://www.uoregon.edu/~koch/texshop/) is very good. Both these applications provide a text editor in addition to the LaTeX processors. Here are a list of excellent resources for learning LaTeX (note that many of these are in psarelated/LaTeX folder on Dropbox):
- Math into LaTeX: An Introduction to LaTeX and MAS-LaTeX (http://tex.loria.fr/general/mil.html). The author has provided a PDF of the first section of the book which is probably sufficient for most. The complete book can be orderd from Amazon here: https://www.amazon.com/More-Math-Into-LaTeX-4th/dp/0387322892/ref=sr_1_1?ie=UTF8&s=books&qid=1258503347&sr=8-1
- The Not So Short Introduction to LaTeX (http://tobi.oetiker.ch/lshort/lshort.pdf)
- If you have to use APA formatting, see http://www.ilsp.gr/homepages/protopapas/apacls.html
Sweave allows for the embedding of R code directly in your LaTeX documents. The best resource is the Sweave User Manual (http://www.stat.uni-muenchen.de/~leisch/Sweave/Sweave-manual.pdf). In short, simply place the following in your LaTeX file:
<
2 + 2
@
There is a Sweave function in R. Issuing the Sweave(file.choose()) command will first prompt for the file (by convention use Rnw file extension), execute all the R code and generate a tex file. This file can then be run through your typical LaTeX processor or editor. Once you go through the Sweave manual, I recommend printing page 13 which lists all the options that can be issued to Sweave.
To create presentations, the Beamer class is what is generally used. The LaTeX beamer class homepage has several exmaples (http://latex-beamer.sourceforge.net/). The Beamer manual is included on Dropbox or when you download the classes (I do believe Beamer is built into both TeXnicCenter and TeXShop).
Laslty, I have included a few of my own files on Dropbox for a recent paper and presentation I’ve done. I used Sweave for the paper (see Bryer.LocatingStudents.Paper.Rnw). I also included the generated LaTeX file (Bryer.LocatingStudents.Paper.tex) as well as the final PDF version. For the presenation, I used Beamer but since I was working from the paper, I simply cut and paste sections from the generated tex file to Bryer.LocationStudents.Presentation.tex. Note the first two lines of this file:
%\documentclass[handout]{beamer}
\documentclass{beamer}
The percent character is a comment line in LaTeX so in order to create the handout version I simply commented out the second line instead of the first. Both versions are included on Dropbox for your review.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.