emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Andreas Leha <andreas.leha@med.uni-goettingen.de>
To: emacs-orgmode@gnu.org
Subject: Re: [babel] noweb reference with default values
Date: Mon, 14 Dec 2015 22:18:20 +0000	[thread overview]
Message-ID: <oluzixc65eb.fsf@med.uni-goettingen.de> (raw)
In-Reply-To: alpine.OSX.2.20.1512140838350.536@charles-berrys-macbook.local

Hi Chuck,

"Charles C. Berry" <ccberry@ucsd.edu> writes:
> 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
>>  <<read_datatable>>
>>  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
>

Thanks!  I am aware of that possibility.  Should have posted a more
involved example.  This works if I only return a table.  Or something
else, that can be passed through Org.  But it fails for instance if the
result is a function (or more functions...).

Regards,
Andreas

  reply	other threads:[~2015-12-14 22:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-14 13:28 [babel] noweb reference with default values Andreas Leha
2015-12-14 16:45 ` Charles C. Berry
2015-12-14 22:18   ` Andreas Leha [this message]
2015-12-17 11:47     ` Andreas Leha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=oluzixc65eb.fsf@med.uni-goettingen.de \
    --to=andreas.leha@med.uni-goettingen.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).