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: inline src_R also in latex src block
Date: Wed, 11 Jan 2012 09:41:40 +0100	[thread overview]
Message-ID: <87aa5uocl7.fsf@med.uni-goettingen.de> (raw)
In-Reply-To: 4f0cc7e9.e4030e0a.7250.4f65@mx.google.com

Michael Bach <phaebz@gmail.com> writes:

> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> would this noweb-based approach work for you:
>>
>> #+name: inner_test
>> #+begin_src R
>>   4 + 4
>> #+end_src
>>
>> #+name: test
>> #+begin_src latex :noweb yes
>>   \begin{equation}
>>     <<inner_test()>>
>>   \end{equation}
>> #+end_src
>>
>
> Yes, that works.  Thanks for your thoughts on this, Andreas.
>
> I am just thinking of another benefit:  Is it correct that I can use
> caching with this approach?  So that the call to <<inner_test()>> does
> not evaluate the `inner_test' block but instead takes its results
> directly from the cached `#+results[6099...]: inner_test' block?  This
> would be speedier than src_R usage...

yes, that should work.  Try to export the following several times.  The
first number should not change.
(note: maybe you'd have to execute the inner_test_cached once on your
system)

#+name: inner_test_cached
#+begin_src R :cache yes :exports none
  rnorm(1)
#+end_src

#+results[dbeb7280be41fdc949815808cf601a6d01a400bb]: inner_test_cached
: 1.12399967834262

#+name: inner_test_not_cached
#+begin_src R :exports none
  rnorm(1)
#+end_src

#+results: inner_test_not_cached
: -0.562660468468834

#+name: test
#+begin_src latex :noweb yes
  \begin{equation}
    <<inner_test_cached()>>
    !=
    <<inner_test_not_cached()>>
  \end{equation}
#+end_src

Cheers,
Andreas

  parent reply	other threads:[~2012-01-11  8:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-30 18:13 inline src_R also in latex src block Michael Bach
2012-01-02 17:49 ` Eric Schulte
2012-01-10 12:25   ` Michael Bach
2012-01-10 13:00     ` Andreas Leha
2012-01-10 23:25       ` Michael Bach
2012-01-11  7:54         ` Sebastien Vauban
2012-01-12 11:57           ` Michael Bach
2012-01-11  8:41         ` Andreas Leha [this message]
2012-01-12 12:00           ` Michael Bach

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=87aa5uocl7.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).