emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Out of Order Evaluation


From: Andreas Leha
Subject: Re: [O] Out of Order Evaluation
Date: Fri, 21 Mar 2014 09:01:14 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Charles Berry <address@hidden> writes:

> Andreas Leha <andreas.leha <at> med.uni-goettingen.de> writes:
>
>> 
>> Hi Michael,
>> 
>> Michael Weylandt <michael.weylandt <at> gmail.com> writes:
>> 
>> > Hi, 
>> >
>> > I want to put a summary of my analysis at the beginning of a document
>> > using results calculated at the end of the document. Is this possible?
>
> [snip]
>
>> >
>> > Is this possible in a single pass? 
>
>
> Not quite. The method suggested by Andreas computes the result twice. If
> there is any randomness in the results (as in the example) you will get a 
> different answer in the summary than when the block is later evaluated.
>

Well, you could enter the ':cache yes' world here.  Although, for me,
that produced more problems than it solved (since there is no tracking
of dependencies among code blocks in :session mode).

My typical workflow now is something 'less literate':  My typical
project Org file will look like this:

--8<---------------cut here---------------start------------->8---
* Execution
This is full of #+call: lines.  By (my own) convention, this subtree has
to be evaluated before exporting the next subsection.

* Report
This is the report / presentation.

* Analysis
This contains all the code block to be called from the Execution
subtree.
(Plus usually quite a lot of code blocks from dead ends of the
project...)
--8<---------------cut here---------------end--------------->8---


This solves your problem (and is along the lines Charles suggests as
well), but requires more work than just export the document and is,
thus, less literate.

Regards,
Andreas



>> > I've played with #+NAME and
>> > <<block()>> but haven't gotten the out-of-order evaluation quite
>> > right.
>
> You can use
>
> #+results: the-mean
>
> before 
>
> #+NAME: the-mean
> #+begin_src R
> mean(x)
> #+end_src
>
> which is after 'theanalysis' block.
>
> And if the format is not pleasing add a filter that reformats the result.
>
>
>> >
>> > Michael
>> >
>> 
>> How about something along:
>> 
>> --8<---------------cut here---------------start------------->8---
>> #+TITLE: Test
>> #+AUTHOR: Michael Weylandt
>> #+PROPERTY: header-args:R :session *__R__* :exports both
>> 
>> * Summary
>> The mean result was src_R[:exports results :var
> analysisresults=theanalysis()]{mean(unlist(analysisresults))}
>> 
>> * Analysis, 
>> We do some complicated calculations: 
>> 
>> #+name: theanalysis
>> #+BEGIN_SRC R
>> x <- rnorm(5)
>> #+END_SRC
>> --8<---------------cut here---------------end--------------->8---
>
>
> It might be better to mark all the blocks in the doc ':eval never'
> and ':exports code' or ':exports none' and put blocks before the first 
> headline that do all the calcs from noweb references, and put the #+results
> lines (if you need them) wherever you want them in the doc. Like so:
>
>
>
> #+TITLE: Test
> #+AUTHOR: Michael Weylandt
> #+PROPERTY: header-args:R :session *__R__* :exports both
>
>
> #+NAME: master
> #+BEGIN_SRC R :noweb yes :results silent :exports results
> <<theanalysis>>
> #+END_SRC
>
> * Summary
>
>
> The mean result was  src_R[:exports results]{mean(x)}
>
> * Analysis, 
> We do some complicated calculations: 
>
> #+name: theanalysis
> #+BEGIN_SRC R :eval never :exports code
> x <- rnorm(5)
> #+END_SRC
>
>
> IMO, needing ':exports results' for inline src blocks is a bug not a
> feature. 
>
> HTH,
>
> Chuck




reply via email to

[Prev in Thread] Current Thread [Next in Thread]