[O] :var problems with R
The following works #+name: xvar #+begin_src emacs-lisp ahaRx #+end_src #+RESULTS: xvar : ahaR #+name: myblock #+begin_src R :var xxx=xvar xxx #+end_src #+RESULTS: myblock : ahaRx But when I replace emacs-lisp with R in the first code block, it does not work any more. I think it should because R also returns the character value in that case. Any ideas?
Re: [O] :var problems with R
Hi Neuwirth, On Thu, Jun 21, 2012 at 8:14 AM, Neuwirth Erich erich.neuwi...@univie.ac.at wrote: The following works #+name: xvar #+begin_src emacs-lisp ahaRx #+end_src Why are you not using something that you know works? Try the following for example. #+name: xvar |ahaRx| #+name: myblock #+begin_src R :var xxx=xvar xxx #+end_src #+RESULTS: myblock : ahaRx As I understand it, Babel can read from tables and lists only. Actually, to me, reading from a block of text doesn't make much sense for a source block. What kind of data structure would it represent (other than a long string of course :-p)? GL -- Suvayu Open source is the future. It sets us free.
Re: [O] :var problems with R
Neuwirth Erich erich.neuwi...@univie.ac.at writes: The following works #+name: xvar #+begin_src emacs-lisp ahaRx #+end_src #+RESULTS: xvar : ahaR #+name: myblock #+begin_src R :var xxx=xvar xxx #+end_src #+RESULTS: myblock : ahaRx But when I replace emacs-lisp with R in the first code block, it does not work any more. I think it should because R also returns the character value in that case. Any ideas? This works here: #+name: xvar #+begin_src R ahaRx #+end_src #+RESULTS: xvar : ahaRx #+name: myblock #+begin_src R :var xxx=xvar xxx #+end_src #+RESULTS: myblock : ahaRx You don't say what doesn't work, which makes it difficult to diagnose what might be going wrong on your end. All the best, Tom -- Thomas S. Dye http://www.tsdye.com
Re: [O] :var problems with R
Meanwhile I learned that #+name: xvar : waterfall #+name: myblock #+begin_src R :var xxx=xvar print(xxx) #+end_src #+RESULTS: myblock : waterfall ans so will #+name: xvar2 : water #+name: myblock2 #+begin_src R :var xxx=xvar2 xxx #+end_src #+RESULTS: myblock2 : water The critical missing piece for me was the colon in front of the value in a name definition. I wanted this because I am running a project on different machines, and I want to give the name od subdirectories through this mechanism. Ir seems cleaner than using code in a programming language when we just need constants. And I explained the problem seems to be that a value returned by R in a named block is not accessible as a named variable. In this case, I would rather stay with R which I need anyhow and I have to explain to my coworkers. Using emacs-lisp additionally would just make things harder to understand fore some of the project members. This also works now #+name: rvar #+begin_src R raha #+end_src #+RESULTS: rvar : raha #+name: rvartest #+begin_src R :var xxx=rvar xxx #+end_src I had misunderstood something there.