[ESS] Suggestion: ess-eval-chunk-and-step

cberry at tajo.ucsd.edu cberry at tajo.ucsd.edu
Wed Oct 17 19:21:07 CEST 2012

Stephen Eglen <S.J.Eglen at damtp.cam.ac.uk> writes:

>> And if you have any opinions about ravel
>>     https://github.com/chasberry/orgmode-accessories/blob/master/ravel-org.md
>> (joining org-mode to Sweave/knitr/brew)
> hi Chuck,
> This sounds very interesting.  Do you have any example org files,
> e.g. to show how to merge org-mode with knitr I would love to see this.



I have posted

-  example-1-Rnw.org :: includes the 'example-1.Rnw’ file from the R
     distribution, but modified to *.org format.

-  knitr-minimal-rhtml.org :: includes a *.org version of the
     knitr-minimal.Rhtml file from the knitr demos page:

- test-cases.org :: see how differently the various exporters treat
                    the src blocks by exporting in different formats:
  - plain latex :: runs src blocks and reports the results

  - latex-noweb :: converts R src blocks to Rnw chunks (runs other

  - latex-brew :: converts R src blocks to '<% ..code.. %>'

In the first two, there is a src block that should export a subtree
containing *.org versions of the original documents - coming close to
recreating the originals. The last one has emacs commands to execute
that generate buffers with the different formats and then run ediff's
them to show what differs.

You need to download ravel.org to run this and follow the instructions
under the "lisp setup" heading.

ravel-org.md is its markdown export, which I have put on github to
enable online browsing (ravel.org does not generate a blob and reading
it in 'raw' format online is painful).

So if you download ravel.org, tangle it to extract e-ravel.el, load
e-ravel.el (assuming <some-path>/org-mode/contrib/lisp is in your
load-path), and you should be ready to run the examples.


I do not have examples of the full workflow I use. 

Currently, I have stuff like this in my working *.org file:

| #+COMMENT:  (org-ravel-export-e-latex-noweb "knitr-clump-graphs.Rnw" t "Rnw")
| #+name: run.knitr.clump
| #+begin_src R :results silent 
|   require(knitr)
|   knit("knitr-clump-graphs.Rnw")
| #+end_src
| #+COMMENT: (pdflatex knitr-clump-graphs")
| #+COMMENT: (shell-command "knitr-clump-graphs.pdf")

So placing the cursor before the src block, C-x C-e produces the knitr
doc, C-c C-c in the src block runs knitr, and then C-x C-e after each of
the comment lines runs latex and opens a viewer on the result.

Then I can navigate to a src block and revise it (or start a new one),
execute it in the org file, and when I am happy with the revision,
navigate to the commands above and rerun them.

I hope to roll up some functions to better automate the part in the
boxquote using the new export menu and ess functions, but for now this
enables me to get work done.

> Stephen

More information about the ESS-help mailing list