emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] inline src_R also in latex src block


From: Andreas Leha
Subject: Re: [O] inline src_R also in latex src block
Date: Wed, 11 Jan 2012 09:41:40 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

Michael Bach <address@hidden> writes:

> Andreas Leha <address@hidden> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]