5

I wish to setup R with LyX. Going through the web I found many resources.

The "official" text doesn't seem to be the most up to date: http://wiki.lyx.org/LyX/LyxWithRThroughSweave

I followed most of the steps here: http://wiki.lyx.org/uploads/LaTeX/SweaveR/lyx_with_r_and_sweave_instructions.pdf But was it really needed? Or is LyX 2.x makes some of them obsolete? From reading this post: http://yihui.name/en/2011/05/sweave-and-pgfsweave-in-lyx-2-0-x-experimental/ I was not so sure anymore.

So my question is - what is the most up to date explanation on how to set up and use LyX with R?

Also - what editor do you find it useful to work with in combination with LyX?

Thanks.

Tal Galili
  • 24,605
  • 44
  • 129
  • 187
  • 4
    I thought LyX had its own WYSIWYG(ish) front end, therefore it wouldn't make sense to edit LyX files in another editor ... ? – Ben Bolker Sep 18 '11 at 22:34
  • Both Ramnath and Ben are right. In LyX 2.0, Sweave support is out-of-the-box. Open a new document, go Document -> Settings -> Modules, then Add Sweave. Be sure to highlight your chunks and set to the "Chunk" environment, and you should be all set. Don't even need Ctrl+Enter any more. – G. Jay Kerns Sep 18 '11 at 23:10
  • Ben - so does LyX include syntax highlighting of R and the likes? Do you develope your code in LyX or in something else which you combine with LyX ? – Tal Galili Sep 19 '11 at 07:44
  • G. Jay - thank you for the reply. Might I ask you if you know of any updated documents which explains how to use these features? – Tal Galili Sep 19 '11 at 07:44
  • 1
    @Tal. Unfortunately, `LyX` does not do syntax highlighting for `R` code. If you use `pgfSweave`, you can get syntax highlighting in the compiled `pdf`. – Ramnath Sep 19 '11 at 11:20

1 Answers1

6

I use LyX 2.0 with Sweave and pgfSweave on a daily basis. LyX 2.0 comes loaded with a module called Sweave which immediately allows you to use Sweave in your documents. If you plan to use pgfSweave, you need to (a) download the pgfSweave module and (b) install some converters. Details are available in the third link you indicated.

Hope this helps.

Ramnath
  • 54,439
  • 16
  • 125
  • 152
  • Hello Ramnath - thank you very much. Could you point me to some of the more updated documents that show how to use these features? – Tal Galili Sep 19 '11 at 07:43
  • I've been working on this for a long while, and I believe pgfSweave will finally get into LyX officially (an optimistic estimation is LyX 2.0.2). However, you do not have to wait for an official release of LyX -- Gregor's original article in R News has explained basically all the mechanics, although LyX 2.0 can save lots of troubles he had at that time. I do not quite recommend other resources, since it has been a really big problem that too many guides (including mine) are around; some are not completely correct and some are outdated. – Yihui Xie Sep 20 '11 at 00:34