tags:

views:

302

answers:

2
+1  Q: 

R code in Sweave

Hi guys,

I have a scientific paper under review, and a referee asked for my R code to be provided as a Sweave document. I've never heard of Sweave before, do you know what's the better way to do it?

Thanks a lot :-)

+5  A: 

A quick google can lead you to a lot of good resources:

See my answer to this question: Getting R plots into LaTeX?

I personally recommend using either LyX or Eclipse (with StatET and TeXlipse) for this, although there are many options for editing LaTeX out there.

Edit:

If your script takes a long time to run, then you can also look at the cacheSweave package.

Shane
Thanks ::-)Point is that my R code requires days to run, and therefore embed it in Sweave mmm seems somehow not indicated!
Thrawn
You never specified that in your question...
Shane
There are caching solutions. Take Shane's advice and Google, this time 'Sweave cache' or something. Also may want to start at rseek.org.
Dirk Eddelbuettel
Thanks guys, I'll try to cache it. Problem is that it was R code that required a month to be run on a cluster :-D
Thrawn
Then don't re-run it. Provide them with the Sweave document. That doesn't mean you need to actually create the paper by running it, so long as the code is the same. Otherwise, the output of Sweave is LaTeX: just replace the R code sections with their output (e.g. tables of data, charts) by directly importing those things into LaTeX just like you would with a regular paper.
Shane
+4  A: 

This seems a very unusual request in my opinion. I can understand a referee expecting you to provide reproducible code, but requiring a specific format is over-the-top. I would respond by providing your code. Sweave is not standard practice for academic journals.

hadley