From mboxrd@z Thu Jan 1 00:00:00 1970 From: Detlef Steuer Subject: Re: Org-mode and ESS Date: Wed, 12 Nov 2008 21:45:23 +0100 Message-ID: <20081112214523.53c864b7@rechenknecht.site> References: <2c75873c0811111000m3c80e8e4rf08b742e80300cd0@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L0Man-0002JG-Lp for emacs-orgmode@gnu.org; Wed, 12 Nov 2008 15:45:37 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L0Mam-0002Ib-Ky for emacs-orgmode@gnu.org; Wed, 12 Nov 2008 15:45:37 -0500 Received: from [199.232.76.173] (port=50097 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L0Mam-0002IU-Gl for emacs-orgmode@gnu.org; Wed, 12 Nov 2008 15:45:36 -0500 Received: from main.gmane.org ([80.91.229.2]:51385 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L0Mam-0003TB-6W for emacs-orgmode@gnu.org; Wed, 12 Nov 2008 15:45:36 -0500 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1L0Maj-0005uS-6P for emacs-orgmode@gnu.org; Wed, 12 Nov 2008 20:45:33 +0000 Received: from e176064248.adsl.alicedsl.de ([85.176.64.248]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 12 Nov 2008 20:45:33 +0000 Received: from detlef.steuer by e176064248.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 12 Nov 2008 20:45:33 +0000 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org This looks just quite cool. :-) I am certainly interested, just starting to prepare a lecture I'll have to give next term and looking for right tool. So, where to grab it? It would be great to collaborate on this, but I fear my emacs skills are _very_ limited. (My only excuse: I converted from VIM to emacs after 15 years ... ESS and org made the difference!) detlef On Wed, 12 Nov 2008 14:42:24 -0500 Austin Frank wrote: > On Tue, Nov 11 2008, Graham Smith wrote: > > > Is any one using Org-mode with ESS. ESS seems to need a file with a > > *.R name to work, but it would be really useful to use Org-mode > > features to keep notes of comments and code, before sending to R, and > > of course to copy results back into an Org-Mode file from R. > > > > As a search here and a google hasn't thrown up anything obvious, I > > assume not, but I thought I would ask. > > In my local git repo of the org sources I have a pretty nice setup for > using R or S inside org-mode. I liked the in-file native editing of > source code so much that I decided that I wanted to use org files as > source files with Sweave (instead of using .Rtex or .Rnw files). My > goal was to export documents with embedded R code, rather than to use > org within the comments of R files. I can certainly see a use for the > latter approach (which seems to be what you have in mind), as well. > > There was recently a thread where someone created a preprocessing system > for specific types of blocks. That would be another possible strategy > for evaluating blocks of R code before export. Since that facility > didn't exist yet and there was already the extensible Sweave > pre-processor, I took the route of making Sweave org-aware. > > > Basically, in the workflow I've developed, I create a file with the > extension .Rorg, say homework_key.Rorg. Within that file, I can embed > blocks of R code, and can refer to variables defined in the R code > contained in the document. > > --8<---------------cut here---------------start------------->8--- > #+BEGIN_R > a <- 3 > a > #+END_R > > * the value of a is \R{a} > * the value of a + 3 is \R{a + 3} > --8<---------------cut here---------------end--------------->8--- > > Executing C-c ' inside the block takes you into a temporary buffer > that's in ESS mode, with full support for interactive evaluation. > > > When I'm ready to export, I run the R command > > Sweave("homework_key.Rorg", driver=RweaveOrgLatex, syntax=SweaveSyntaxOrg). > > (I've defined those driver and syntax functions locally). This creates > a new file, homework_key.org. In the new file, the above text would be > translated into > > --8<---------------cut here---------------start------------->8--- > #+BEGIN_LATEX > \begin{Schunk} > \begin{Sinput} > > a <- 3 > > a > \end{Sinput} > \begin{Soutput} > [1] 3 > \end{Soutput} > \end{Schunk} > #+END_LATEX > > * the value of a is 3 > * the value of a + 3 is 6 > --8<---------------cut here---------------end--------------->8--- > > The plain homework_key.org file could then be exported into \LaTeX. It > even works with the new pdf export. > > > I haven't put the code anywhere public because there are several things > I still need to do: > > - test graphic creation and export > - improve generation of latex headers > - automate processing from .Rorg to .tex (or .pdf) (currently at least 3 > steps, should be 1) > - come up with suggested keybindings for inserting the #+BEGIN/END_R > blocks > - create a driver to generate HTML instead of \LaTeX > > Still, it is in a works-for-me state at the moment, and I could send a > pull request to Carsten or could push it worg if folks were interested. > > Let me know, > /au > > > -- > Austin Frank > http://aufrank.net > GPG Public Key (D7398C2F): http://aufrank.net/personal.asc > -- Wisely, and slow. They stumble that run fast. - Shakespeare