From mboxrd@z Thu Jan 1 00:00:00 1970 From: cberry@tajo.ucsd.edu Subject: Re: conditional export based on babel result Date: Thu, 06 Sep 2012 12:07:53 -0700 Message-ID: <87vcfr3r7a.fsf@tajo.ucsd.edu> References: <87k3w8bq9z.fsf@med.uni-goettingen.de> <87fw6wqr2b.fsf@gmx.com> <87wr08b8bc.fsf@med.uni-goettingen.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:56163) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9hR1-0001NF-7n for emacs-orgmode@gnu.org; Thu, 06 Sep 2012 15:08:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T9hQz-0007J1-OQ for emacs-orgmode@gnu.org; Thu, 06 Sep 2012 15:08:15 -0400 Received: from plane.gmane.org ([80.91.229.3]:43903) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9hQz-0007Ix-Hf for emacs-orgmode@gnu.org; Thu, 06 Sep 2012 15:08:13 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1T9hQy-0005jV-PE for emacs-orgmode@gnu.org; Thu, 06 Sep 2012 21:08:12 +0200 Received: from tajo.ucsd.edu ([137.110.122.165]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 06 Sep 2012 21:08:12 +0200 Received: from cberry by tajo.ucsd.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 06 Sep 2012 21:08:12 +0200 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 writes: I am a bit late to the thread, but two possibilities come to mind: 1) write a brew template as #+name: brewtemp #+begin_src latex ... #end_src block then call it as #+begin_src R :noweb yes :results output latex brew(text= <> ) #+end_src Brew allows loops and conditionals over both markup and code, which allows you to choose or skip a sub-document as the R code dictates. If the sub-document is of modest size and complexity, this is reasonably easy and the brew markup will be easy to read. 2) Use ravel (at https://github.com/chasberry/orgmode-accessories/) to export an org subtree as a knitr parent document in Rnw format (akin to Sweave) and another org subtree as a knitr child document. The parent document must call the child from within a code block to allow loops and conditionals. Then run knitr. For more complicated sub-documents, this might work better than building brew templates in latex src blocks as editting the org structure and retooling R src blocks is easier (for me at least) than re-organizing a lengthy latex src block with embedded brew calls. HTH, Chuck > Eric Schulte writes: > >> Andreas Leha writes: >> >>> Hi all, >>> >>> is there a possibility to exclude (or include) parts of the document >>> based on some babel source block result? >>> >>> First some use case: >>> Say, I am doing a statistical test. And only if the test turns out to be >>> significant, a follow-up analysis is carried out. >>> >>> Is that possible? >>> >>> One thinkable and ugly option would be to allow lisp-generated tags like >>> in this dummy example: >>> >>> #+begin_org >>> >>> * The Test >>> #+name: sometest >>> #+begin_src R >>> test_result <- 0.03 >>> #+end_src >>> >>> >>> ** export maybe (if (< (string-to-number (sbe sometest)) 0.05) ":export:" ":noexport:") >>> The follow-up >>> >>> #+end_org >>> >>> >>> Regards, >>> Andreas >>> >>> >> >> Hi Andreas, >> >> When doing something this complex you may just want to write your own >> function which could say... take a subtree ID and a boolean flag as >> arguments and then set the export flag on that subtree as appropriate. >> >> The org-id-goto and org-toggle-comment functions may help in >> implementing this function. >> >> Best, > > Hi Eric, > > in my opinion, there are more complex things in org-mode already ;-) > > I agree, that such functionality doesn't need to be provided in org > itself. > Thanks a lot for the pointers to possible entry-points for an > implementation. I hope, I'll find time to to go for it. Would be good > for my elisp, anyway... > > Regards, > Andreas > > > -- Charles C. Berry Dept of Family/Preventive Medicine cberry at ucsd edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901