From mboxrd@z Thu Jan 1 00:00:00 1970 From: Charles Berry Subject: Re: Out of Order Evaluation Date: Fri, 21 Mar 2014 01:34:10 +0000 (UTC) Message-ID: References: <8AE0B11E-8EA2-41A8-8D0C-CDB610785239@gmail.com> <87lhw4cyd5.fsf@med.uni-goettingen.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQoM9-0002tg-SM for emacs-orgmode@gnu.org; Thu, 20 Mar 2014 21:34:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQoM3-00081V-Nq for emacs-orgmode@gnu.org; Thu, 20 Mar 2014 21:34:45 -0400 Received: from plane.gmane.org ([80.91.229.3]:54928) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQoM3-00081R-H6 for emacs-orgmode@gnu.org; Thu, 20 Mar 2014 21:34:39 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WQoM0-0002ni-CF for emacs-orgmode@gnu.org; Fri, 21 Mar 2014 02:34:36 +0100 Received: from 137.110.32.33 ([137.110.32.33]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 21 Mar 2014 02:34:36 +0100 Received: from ccberry by 137.110.32.33 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 21 Mar 2014 02:34:36 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Andreas Leha med.uni-goettingen.de> writes: > > Hi Michael, > > Michael Weylandt 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. > > I've played with #+NAME and > > <> 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: --8<---------------cut here---------------start------------->8--- #+TITLE: Test #+AUTHOR: Michael Weylandt #+PROPERTY: header-args:R :session *__R__* :exports both #+NAME: master #+BEGIN_SRC R :noweb yes :results silent :exports results <> #+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 --8<---------------cut here---------------end--------------->8--- IMO, needing ':exports results' for inline src blocks is a bug not a feature. HTH, Chuck