3

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 :-)

mdsumner
  • 29,099
  • 6
  • 83
  • 91
Federico Giorgi
  • 10,495
  • 9
  • 42
  • 56
  • 4
    Closely related: http://stackoverflow.com/questions/1379549/recommendations-for-developing-sweave-documents – Shane Mar 18 '10 at 17:45
  • It is not 'your R code to be provided as a Sweave document' as Sweave combines LaTeX and R automagically. So your *paper* becomes an Sweave document. – Dirk Eddelbuettel Mar 18 '10 at 17:46
  • So do they mean I should rewrite the whole paper in LaTeX?? Because they specifically write I should provide the R code as a Sweave document. – Federico Giorgi Mar 18 '10 at 17:47
  • 1
    Then I hope the referee never reads this post :-D Because I'm not going to learn LaTeX in one week for him. – Federico Giorgi Mar 18 '10 at 17:53
  • 5
    I just want to take this opportunity to salute the referee for this paper - requiring submissions in Sweave is fantastic (for reproducibility, understandability, etc.), even if it's not going to be possible in this case. =) – Ken Williams Mar 18 '10 at 18:15

2 Answers2

6

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.

Community
  • 1
  • 1
Shane
  • 98,550
  • 35
  • 224
  • 217
  • Thanks ::-) Point is that my R code requires days to run, and therefore embed it in Sweave mmm seems somehow not indicated! – Federico Giorgi Mar 18 '10 at 17:45
  • 2
    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 Mar 18 '10 at 17:48
  • 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 – Federico Giorgi Mar 18 '10 at 17:48
  • 2
    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 Mar 18 '10 at 17:55
6

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
  • 102,019
  • 32
  • 183
  • 245