From mboxrd@z Thu Jan 1 00:00:00 1970 From: Austin Frank Subject: Re: Org-mode and ESS Date: Wed, 12 Nov 2008 14:42:24 -0500 Message-ID: References: <2c75873c0811111000m3c80e8e4rf08b742e80300cd0@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1177731018==" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L0Lc2-000629-BA for emacs-orgmode@gnu.org; Wed, 12 Nov 2008 14:42:50 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L0Lc0-00061W-Nt for emacs-orgmode@gnu.org; Wed, 12 Nov 2008 14:42:49 -0500 Received: from [199.232.76.173] (port=51348 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L0Lc0-00061M-Co for emacs-orgmode@gnu.org; Wed, 12 Nov 2008 14:42:48 -0500 Received: from main.gmane.org ([80.91.229.2]:40432 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 1L0Lbz-0006NP-Nh for emacs-orgmode@gnu.org; Wed, 12 Nov 2008 14:42:48 -0500 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1L0Lbv-0003Xh-Ef for emacs-orgmode@gnu.org; Wed, 12 Nov 2008 19:42:43 +0000 Received: from colossus.cvs.rochester.edu ([128.151.80.181]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 12 Nov 2008 19:42:43 +0000 Received: from austin.frank by colossus.cvs.rochester.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 12 Nov 2008 19:42:43 +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 --===============1177731018== Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --=-=-= Content-Transfer-Encoding: quoted-printable 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. =2D-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}=20=20 =2D-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=3DRweaveOrgLatex, syntax=3DSweaveSynta= xOrg). (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 =2D-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 =2D-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. =20=20 I haven't put the code anywhere public because there are several things I still need to do: =2D test graphic creation and export =2D improve generation of latex headers =2D automate processing from .Rorg to .tex (or .pdf) (currently at least 3 steps, should be 1) =2D come up with suggested keybindings for inserting the #+BEGIN/END_R blocks =2D 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 =2D-=20 Austin Frank http://aufrank.net GPG Public Key (D7398C2F): http://aufrank.net/personal.asc --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Darwin) iEYEARECAAYFAkkbMaAACgkQlHMl2/XbR4EEHACeJws/gNgmXzr2/tqrhFmNv7oW bJgAoLkJcE++cgaZiI16UgKcEqgLFJan =anb2 -----END PGP SIGNATURE----- --=-=-=-- --===============1177731018== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --===============1177731018==--