* Org-mode and ESS @ 2008-11-11 18:00 Graham Smith 2008-11-11 18:30 ` Detlef Steuer 2008-11-12 19:42 ` Austin Frank 0 siblings, 2 replies; 10+ messages in thread From: Graham Smith @ 2008-11-11 18:00 UTC (permalink / raw) To: emacs-orgmode 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. Thanks, Graham ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Org-mode and ESS 2008-11-11 18:00 Org-mode and ESS Graham Smith @ 2008-11-11 18:30 ` Detlef Steuer 2008-11-11 19:13 ` Graham Smith 2008-11-12 19:42 ` Austin Frank 1 sibling, 1 reply; 10+ messages in thread From: Detlef Steuer @ 2008-11-11 18:30 UTC (permalink / raw) To: emacs-orgmode Hi Graham, if you have ess loaded and you are working on a file test.org: * test ls() and you have an R process running in another buffer, then you can i.e. put the cursor on the line with ls() in test.org and execute M-x ess-eval-line. The command is then executed in your running R session. Hth detlef On Tue, 11 Nov 2008 18:00:01 +0000 "Graham Smith" <myotisone@gmail.com> 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. > > Thanks, > > Graham > > > _______________________________________________ > 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 > -- Wisely, and slow. They stumble that run fast. - Shakespeare ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Re: Org-mode and ESS 2008-11-11 18:30 ` Detlef Steuer @ 2008-11-11 19:13 ` Graham Smith 0 siblings, 0 replies; 10+ messages in thread From: Graham Smith @ 2008-11-11 19:13 UTC (permalink / raw) To: emacs-orgmode Detlef, Ah thanks, I should probably worked that out myself. > if you have ess loaded and you are working on a file test.org: > > * test > ls() > > and you have an R process running in another buffer, then > you can i.e. put the cursor on the line with ls() in test.org > and execute M-x ess-eval-line. > The command is then executed in your running R session. Graham ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Org-mode and ESS 2008-11-11 18:00 Org-mode and ESS Graham Smith 2008-11-11 18:30 ` Detlef Steuer @ 2008-11-12 19:42 ` Austin Frank 2008-11-12 19:51 ` Graham Smith ` (2 more replies) 1 sibling, 3 replies; 10+ messages in thread From: Austin Frank @ 2008-11-12 19:42 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1.1: Type: text/plain, Size: 3300 bytes --] 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 [-- Attachment #1.2: Type: application/pgp-signature, Size: 193 bytes --] [-- Attachment #2: Type: text/plain, Size: 204 bytes --] _______________________________________________ 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Re: Org-mode and ESS 2008-11-12 19:42 ` Austin Frank @ 2008-11-12 19:51 ` Graham Smith 2008-11-12 20:45 ` Detlef Steuer 2008-11-13 3:22 ` Eric Schulte 2 siblings, 0 replies; 10+ messages in thread From: Graham Smith @ 2008-11-12 19:51 UTC (permalink / raw) To: Austin Frank; +Cc: emacs-orgmode Austin > In my local git repo of the org sources I have a pretty nice setup for > using R or S inside org-mode. I did see the original posts on this, and was interested in what you were doing, but its a bit beyond me at the moment while I am still trying to grasp how Emacs/org works. At the moment, as you surmised I am just looking to add a bit of structure to the notes I make while working on an analysis. But I may well come back to what you are doing, as I become more comfortable with Emacs. Thanks, Graham ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Org-mode and ESS 2008-11-12 19:42 ` Austin Frank 2008-11-12 19:51 ` Graham Smith @ 2008-11-12 20:45 ` Detlef Steuer 2008-11-13 3:22 ` Eric Schulte 2 siblings, 0 replies; 10+ messages in thread From: Detlef Steuer @ 2008-11-12 20:45 UTC (permalink / raw) To: emacs-orgmode 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 <austin.frank@gmail.com> 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Re: Org-mode and ESS 2008-11-12 19:42 ` Austin Frank 2008-11-12 19:51 ` Graham Smith 2008-11-12 20:45 ` Detlef Steuer @ 2008-11-13 3:22 ` Eric Schulte 2008-11-13 5:40 ` Austin Frank 2 siblings, 1 reply; 10+ messages in thread From: Eric Schulte @ 2008-11-13 3:22 UTC (permalink / raw) To: Austin Frank; +Cc: emacs-orgmode Austin Frank <austin.frank@gmail.com> writes: > 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. Hi Austin, I would be interested to help extend the block prepreocessing system to handle cases like the one you mention here. > > 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. > > #+BEGIN_R > a <- 3 > a > #+END_R > > * the value of a is \R{a} > * the value of a + 3 is \R{a + 3} > In the above example how would you/Sweave handle the case where there are multiple R blocks in the same file? For example #+BEGIN_R a <- 3 a #+END_R - the value of a is \R{a} - the value of a + 3 is \R{a + 3} #+BEGIN_R a <- 8 a #+END_R - the value of a is \R{a} - the value of a + 3 is \R{a + 3} With that questions answered it should be relatively straightforward to implement exporting as you described using only org-mode's block processing, and letting ESS do the actual calculations all without any dependence on Sweave. > I haven't put the code anywhere public because there are several things > I still need to do: > > - test graphic creation and export if you have examples of graphic creation, I'd be interested to see how they work, and relatedly how difficult it would be to move that functionality into org-mode. However I think the rest of the point you make immediately below would be easily addressed through using an org-mode only approach. > - 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 If you happen to use yasnippets, I find it makes the creation of blocks in org files a very quick/easy experience. See http://legito.net/worg/org-configs/index.php#sec-2.1 for details. > > - create a driver to generate HTML instead of \LaTeX > Cheers -- Eric ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Org-mode and ESS 2008-11-13 3:22 ` Eric Schulte @ 2008-11-13 5:40 ` Austin Frank 2008-11-14 1:22 ` Eric Schulte 0 siblings, 1 reply; 10+ messages in thread From: Austin Frank @ 2008-11-13 5:40 UTC (permalink / raw) To: Eric Schulte; +Cc: emacs-orgmode [-- Attachment #1.1.1: Type: text/plain, Size: 3355 bytes --] On Wed, Nov 12 2008, Eric Schulte wrote: > In the above example how would you/Sweave handle the case where there > are multiple R blocks in the same file? For example Sweave puts all variables defined in a document into the same environment. So assigning to a twice overwrites the first assignment. ,----[ tmp2.Rorg ] | #+BEGIN_R | a <- 3 | a | #+END_R | | - the value of a is \R{a} | - the value of a + 3 is \R{a + 3} | | #+BEGIN_R | a <- 8 | a | #+END_R | | - the value of a is \R{a} | - the value of a + 3 is \R{a + 3} `---- ,----[ tmp2.org ] | #+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 | | #+BEGIN_LaTeX | \begin{Schunk} | \begin{Sinput} | > a <- 8 | > a | \end{Sinput} | \begin{Soutput} | [1] 8 | \end{Soutput} | \end{Schunk} | #+END_LaTeX | | - the value of a is 8 | - the value of a + 3 is 11 `---- > With that questions answered it should be relatively straightforward > to implement exporting as you described using only org-mode's block > processing, and letting ESS do the actual calculations all without any > dependence on Sweave. There is a Sweave.sty that handles formatting of the Schunk, Sinput, and Soutput environments. While you may not need to depend on Sweave for the preprocessing step, it would be nice if the formatted document at least had the option of having the same appearance as Sweave-processed files. Still, I suppose I could just add a #+LATEX_HEADER line for these files. > if you have examples of graphic creation, I'd be interested to see how > they work, and relatedly how difficult it would be to move that > functionality into org-mode. OK, here comes the first attempt. The additional feature demonstrated in this example is the inclusion of options to the Sweave preprocessor at the beginning of the block. In this case I've specified fig=TRUE to tell the preprocessor to generate image files for the plot commands contained in the block. By default, Sweave creates a .eps and a .pdf file for each block that contains a plotting or printing command and has the fig=TRUE argument, and then inserts an \includegraphics{} command in the output file. ,----[ tmp3.Rorg ] | * first figure | #+BEGIN_R fig=TRUE | x <- rnorm(100) | y <- rnorm(100) | | plot(x,y) | #+END_R `---- ,----[ tmp3.org ] | * first figure | #+BEGIN_LaTeX | \begin{Schunk} | \begin{Sinput} | > x <- rnorm(100) | > y <- rnorm(100) | > plot(x, y) | \end{Sinput} | \end{Schunk} | #+END_LaTeX | #+LaTeX: \includegraphics{tmp3-001} `---- ,----[ tmp3.tex ] | % Created 2008-11-12 Wed 23:46 | \documentclass[11pt,a4paper]{article} | \usepackage[utf8]{inputenc} | \usepackage[T1]{fontenc} | \usepackage{graphicx} | \usepackage{hyperref} | \usepackage{Sweave} | | \title{tmp3} | \author{Austin Frank} | \date{12 November 2008} | | \begin{document} | | \maketitle | | | \section*{first figure} | \label{sec-1} | | \begin{Schunk} | \begin{Sinput} | > x <- rnorm(100) | > y <- rnorm(100) | > plot(x, y) | \end{Sinput} | \end{Schunk} | \includegraphics{tmp3-001} | | \end{document} `---- And the pdf is attached. [-- Attachment #1.1.2: tmp3.pdf --] [-- Type: application/pdf, Size: 30353 bytes --] [-- Attachment #1.1.3: Type: text/plain, Size: 3021 bytes --] I haven't looked into it too closely, but I would guess that when fig=TRUE is specified, first the R block is run, and then the additional R commands dev.copy2eps() dev.copy2pdf() are run. This results in the creation of eps and pdf files based on the last thing plotted. The functions could each take a file="foo" argument (the filename defaults to Rplots.[eps|pdf]). Sweave uses automatically incremented names for its generated graphics files. If your block system could have an after-block hook, you could evaluate the original block, then the appropriate dev.copy function, and then add an additional line to the exported file for inclusion of the graphics file. > However I think the rest of the point you make immediately below would > be easily addressed through using an org-mode only approach. Exciting! If you're interested in what other options the Sweave preprocessor contains, the manual can be found at http://www.stat.auckland.ac.nz/~dscott/782/Sweave-manual-20060104.pdf. Sweave also has a processing option called "tangle". This extracts all of the R code from a document and puts into its own file. This would be a useful feature in a generic block exporter as well, I would think. Take all of the blocks of a certain type and dump the content into a file with the appropriate extension for whatever the major mode was for that block. Finally , a couple of systems for caching Sweave output have sprung up. I think these use the strategy of hashing the content of each block, saving the output of each block, and only re-running the block if the content has changed. A general-purpose option like this for the block exporting system in org could be very nice to have. It's possible that the attachment system with git integration already gets us very close to a working version of this. The more I think about this last possibility, the more potential I think it has. With the caching turned on, at export time you create files containing the contents of each block to be cached, one file per block. You create a second set of files that has the results of block export, again one file per block. You add the directory of block files and results using org-attach. On the next export, block files are generated again. You use git to ask which ones have changed. For those that have changed, you go on to do the normal block export, saving the results again. Finally, you pull the results files back into the original document in the right places. It would be neat if something like this could work. > If you happen to use yasnippets, I find it makes the creation of > blocks in org files a very quick/easy experience. See > http://legito.net/worg/org-configs/index.php#sec-2.1 for details. I'll check it out, thanks. Sorry to ramble, hope this was useful! Looking forward to seeing what you come up with! /au -- Austin Frank http://aufrank.net GPG Public Key (D7398C2F): http://aufrank.net/personal.asc [-- Attachment #1.2: Type: application/pgp-signature, Size: 193 bytes --] [-- Attachment #2: Type: text/plain, Size: 204 bytes --] _______________________________________________ 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Org-mode and ESS 2008-11-13 5:40 ` Austin Frank @ 2008-11-14 1:22 ` Eric Schulte 2008-11-16 1:50 ` Eric Schulte 0 siblings, 1 reply; 10+ messages in thread From: Eric Schulte @ 2008-11-14 1:22 UTC (permalink / raw) To: Austin Frank; +Cc: emacs-orgmode Austin Frank <austin.frank@gmail.com> writes: > On Wed, Nov 12 2008, Eric Schulte wrote: > > > I'll check it out, thanks. Sorry to ramble, hope this was useful! > Not at all, this is all very interesting. I've never used Sweave, but I have been using org-mode for "reproducible research" type functionality on some of my projects at work, and this is right up my alley. > > Looking forward to seeing what you come up with! Me too :) Hopefully I will continue to be able to put time into this. I hope you don't mind, I've populated my TODO files with much of the text from your last email. I'm keeping my development mirrored on github at http://github.com/eschulte/org-contrib/tree/master and as usual, I will be sure to post to the list if anything really good emerges. Thanks -- Eric > > /au ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Org-mode and ESS 2008-11-14 1:22 ` Eric Schulte @ 2008-11-16 1:50 ` Eric Schulte 0 siblings, 0 replies; 10+ messages in thread From: Eric Schulte @ 2008-11-16 1:50 UTC (permalink / raw) To: Austin Frank; +Cc: emacs-orgmode "Eric Schulte" <schulte.eric@gmail.com> writes: > Austin Frank <austin.frank@gmail.com> writes: > >> Looking forward to seeing what you come up with! > > Me too :) Hopefully I will continue to be able to put time into this. I > hope you don't mind, I've populated my TODO files with much of the text > from your last email. I'm keeping my development mirrored on github at > > http://github.com/eschulte/org-contrib/tree/master > > and as usual, I will be sure to post to the list if anything really good > emerges. > Just to update. The basic Sweave type processing of R blocks and \R{} chunks is now working for both html and latex exporting. Please take a look and let me know if there are parts which aren't working as expected. I haven't started looking at the image creation yet. Cheers -- Eric ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-11-16 1:50 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-11-11 18:00 Org-mode and ESS Graham Smith 2008-11-11 18:30 ` Detlef Steuer 2008-11-11 19:13 ` Graham Smith 2008-11-12 19:42 ` Austin Frank 2008-11-12 19:51 ` Graham Smith 2008-11-12 20:45 ` Detlef Steuer 2008-11-13 3:22 ` Eric Schulte 2008-11-13 5:40 ` Austin Frank 2008-11-14 1:22 ` Eric Schulte 2008-11-16 1:50 ` Eric Schulte
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).