[OS X TeX] R statistics package

Chabot Denis chabotd at globetrotter.net
Thu Feb 22 03:09:55 CET 2007


Hi,

Le 07-02-21 à 20:00, TeX on Mac OS X Mailing List a écrit :

> Subject: Re: [OS X TeX] R statistics package
> From: "Michael Kubovy" <kubovy at virginia.edu>
> Date: Wed, 21 Feb 2007 19:42:49 -0500
>
> Hi Enrico,
>
> On Feb 21, 2007, at 1:26 PM, Salvatore Enrico Indiogine wrote:
>
>> From some Googling I see that is is possible to integrate R and  
>> LaTeX.
>> I tried an Sweave example but it does not work.  I bet I have to
>> install some R and/or LaTeX packages.
>
> ************ Create the .Rnw file ******************
> Choose a working directory, e.g., in my case "/Users/mk/Documents/"
> In that directory create a file called "try.Rnw":
> ******
> \documentclass[]{article}
> \usepackage{graphicx}
>
> \title{Brief Article}
> \author{The Author}
>
> \begin{document}
> \maketitle
>
> Hello, Sweave!
>
> <<plot, include = T, fig = T>>=
> x <- 1:10
> y <- x^2
> plot(x, y)
> @
>
> \end{document}
> ******
>
> ************ Run Sweave() on the .Rnw file ******************
> In R type
> setwd('/Users/mk/Documents/')
> Sweave('try.Rnw')
>
> Now you will have "try.tex" in your directory together with two files
> "try-plot.pdf" and "try-plot.eps"
>
> ************ Compile the .tex file ******************
> Open try.tex and compile it.
>
> ************ RTFM ******************
> http://www.ci.tuwien.ac.at/~leisch/Sweave/Sweave-manual-20060104.pdf
> and perhaps
> http://www.stat.psu.edu/~dhunter/R/html/utils/html/Sweave.html
>
> The learning curve is shallow, but repays patience.
> _____________________________
> Professor Michael Kubovy

I use Sweave and could not have explained it better than Michael did.  
It is a really nice option to document your analyses. Otherwise I  
have the bad habit of getting countless plots and analyses and a few  
months later I wonder what was done in what order and exactly for  
what reason. With Sweave I have a nice document explaining the whole  
thing. Better yet, you need to correct your data: you recompile your  
Sweave document, then the resulting tex document, and everything is  
redone with the corrected data.

For a paper or a report, I do not work this way, I write it in LaTeX  
only because I'll probably only need to include a few pdf graphics  
produced with R. However my reason for doing this was that TeXShop  
does not have the proper syntax highlighting for Sweave, and  
TextWrangler either (I normally use the former for tex document and  
the latter for R documents. However I'll explore what Charilaos  
Skiadas has said about TextMate, maybe I'll use Sweave even more  
often if I get proper syntax highlighting.

Denis


------------------------- Helpful Info -------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/
List Reminders & Etiquette: http://www.esm.psu.edu/mac-tex/list/





More information about the macostex-archives mailing list