I am trying to setup like the following in the top section of my .org file. But it does not work, all the parameters are not passed into the subsequent R code blocks.

 #+BABEL: :session *R* :cache yes :results output graphics :exports both :tangle yes

Doing like the following works. But it forces every code block to have :file parameter set. I don't want that because I have some code blocks which do not have graphic output.

#+PROPERTY: session *R*
#+PROPERTY: cache yes
#+PROPERTY: results graphics
#+PROPERTY: exports both
#+PROPERTY: tangle yes

How do I setup this? I prefer one-liner setup like "+BABEL:...." and customize the code blocks that I want differently.


One solution may be to add a PROPERTIES drawer at the heading level e.g.

:header-args: :session *R* :cache yes :results output graphics :exports both :tangle yes

If you do this, you cannot override individual parameters with another header-args in a PROPERTIES drawer as this overrides the whole line, but you can override indivudal parameters on the #+begin_src declaration.

  • This works for all paramenters in there, except for the session *R* part. I still have to use the #+PROPERTY: session *R* syntax. Sep 19 '16 at 13:35
  • That's odd - I don't use session much (prefer code blocks idempotent) but I can't see a reason why it would be different. The session arg just gives a name to the session does it not. Random guess: maybe something else is interpreting the * - can you try calling it something different?
    – Matt Innes
    Sep 21 '16 at 11:15
  • Can you elaborate your setup? I have no reason to stick to the non-working setup. With that said, reading through the latest orgmode docs, this should work but I haven't tried: ` #+PROPERTY: header-args:R :session *R*` Sep 21 '16 at 18:35
  • I've been using something similar for SQL - this allows me to define the database parameters at the heading level then just write SQL in src blocks and it just works - but I don't need sessions. The header-args:R syntax is to specifiy particular args are relevent to particular languages - if session in this instance is an R specific arg then that may fix your issue. :PROPERTIES: :header-args: :engine "mysql" :dbuser "dbuser" :dbpassword "password" :dbhost "" :database "dbname" :var dbuser="dbuser" :END:
    – Matt Innes
    Sep 22 '16 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.