From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Charles C. Berry" Subject: Re: [babel] noweb reference with default values Date: Mon, 14 Dec 2015 08:45:39 -0800 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8WFx-00056d-I5 for emacs-orgmode@gnu.org; Mon, 14 Dec 2015 11:45:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a8WFs-0008QA-Eo for emacs-orgmode@gnu.org; Mon, 14 Dec 2015 11:45:49 -0500 Received: from iport-acv2-out.ucsd.edu ([132.239.0.174]:7521) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a8WFs-0008Po-60 for emacs-orgmode@gnu.org; Mon, 14 Dec 2015 11:45:44 -0500 In-Reply-To: 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: Andreas Leha Cc: emacs-orgmode@gnu.org On Mon, 14 Dec 2015, Andreas Leha wrote: > Hi all, > > I'd like to hear your ideas on how to include noweb references to code > blocks in a way that the default values are used as parameter values. > > Here is a little example: > > #+PROPERTY: header-args:R :session *testR* > > The background is that I like to use Org mode table to record small data. > > #+name: datatable > | A | B | > |---+----| > | 1 | 10 | > | 2 | 20 | > > Usually I want to pre-process and/or convert such data. > > #+name: read_datatable > #+header: :var datatable=datatable > #+begin_src R :results none > datatable$B <- 10 * datatable$B > #+end_src > > Later I would like to use that data in larger (R-) code blocks. I'd > like such code blocks to DWIM: > > #+name: some_code > #+begin_src R :noweb yes :results graphics :file testplot.png > <> > plot(datatable$A, datatable$B) > #+end_src > > But they do not: They are not stand alone and do not execute -- unless I > executed `read_datatable' manually/by chance upfront. Try this: #+name: read_datatable #+header: :var datatable=datatable #+begin_src R :results value :colnames yes datatable$B <- 10 * datatable$B datatable #+end_src #+name: some_code #+HEADER: :var datatable=read_datatable() #+begin_src R :noweb yes :results graphics :file testplot.png plot(datatable$A, datatable$B) #+end_src HTH, Chuck