|
From: | Matthew Landis |
Subject: | Re: [O] Selectively export RESULTS |
Date: | Fri, 02 Mar 2012 13:53:48 -0500 |
User-agent: | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 |
On 3/2/2012 12:59 PM, Christophe Pouzat wrote:
Christophe - thanks for the suggestion. I haven't messed around much with variables passed between code blocks. When I try this, R tells me that 'x' must be numeric. When I query x in the R buffer, x is a data.frame. So the second code block reads x in as a data.frame instead of a numeric vector.Matthew, I think that you're wrongly expecting babel's cache header argument to behave like the argument of the same name in Sweave code chunks. Babel will cache, in your case, the value of your code block evaluation and there is none in your first code block, therefore nothing gets cached by babel, try that instead: #+name: my-random-vector #+begin_src R :session :cache yes rnorm(100) #+end_src #+headers: :var x=my-random-vector #+headers: :results graphics :exports results :file hist.png #+begin_src R :session :cache yes hist(x) #+end_src Does it work better? In that case you don't even need a session. Christophe
For most purposes this would be OK (since a data.frame is the most usual outcome), but I'm reluctant to use this approach -- I'd like all of the variable passing to be in the R session. Intuitively this seems simpler, less error prone, and more conducive to tangling later. (Of course, I could be totally wrong - since I haven't really tried that approach).
M -- ~~~~~~~~~~~~~~~~~~~~~~~~~~ Matthew Landis, Ph.D. Research Scientist ISciences, LLC 61 Main St. Suite 200 Burlington VT 05401 802.864.2999 www.isciences.com ~~~~~~~~~~~~~~~~~~~~~~~~~~
[Prev in Thread] | Current Thread | [Next in Thread] |