There is a Latex development environment made specially for the Mac. It's called TeXShop?.

Most recent web location: http://www.uoregon.edu/~koch/texshop/obtaining.html

MacTeX is a large download, over a gigabyte. To obtain it, go here: http://www.tug.org/mactex/.

Once the installation is done, it resides in > Applications > Tex > TeXShop

TeXShop is a development environment for LaTex, and it comes with an editor that uses some of the emacs commands.Sweave

Sweave (note the capital S) comes with R. Useful web documentation is here: http://www.stat.umn.edu/~charlie/Sweave/foo.pdf

To get it to work, first create a LaTeX file containing calls to R embedded in the appropriate Sweave incantations, and make sure the file has the extension Rnw. If you like, you can use thisSimpleSweaveTest.Rnw. Then use the commands below in R.

To produce the tex file, do: > Sweave("SimpleSweaveTest.Rnw")

Then add the tools library: > library(tools)

Now we can make the pdf file.

> texi2dvi("SimpleSweaveTest.tex", pdf = TRUE)

\SweaveInclude{}

In long documents it can be tricky to edit the document and reorder sections because you might end up reordering R code in such a way as to break it. A solution for this is to use the command \SweaveInclude{<file>}. Note the capital S and I. If you put all (or really, almost all) of your R code into its own Rnw file, say myfile.Rnw, you can then make the first first line of your document after \maketitle be \SweaveInput{myfile.Rnw}. That causes all the code to be executed first. Then, interspersed throughout the rest of the document you can have tables and figures referring to variables that are defined in the code file. The entire code file could look like this:
<<include=F,echo=F>>=
foo <- 1:10

@
The include=F and echo=F almost insure that the results of computation don't end up in the Sweave output file. As it happens, if you call a function whose sole purpose is to produce output, like print() or round(), the output still seems to show up in the tex file even with include=F and echo=F.

The file has the R code sandwiched between <<>>= and @. It does NOT need any of the other tex and Sweave commands like

\documentclass[11pt]{article}
\usepackage{geometry}.

Emacs Sweave Template

The boilerplate for an Sweave file is included in an emacs function in the file DotEmacs. The way to use it is first to visit your new file, e.g. mynewfile.Rnw, and then invoke the function is M-x sweave-template (with a small s).