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.

2 Answers 2


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. Commented Sep 19, 2016 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
    Commented Sep 21, 2016 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*` Commented Sep 21, 2016 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
    Commented Sep 22, 2016 at 10:34

Attempting to improve on the previous answer:

One solution is to use #+PROPERTY :header-args: for file level parameters. For example:

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

Another solution may be to add a PROPERTIES drawer at the heading level, for example:

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

Furthermore, you can override :header-args: at lower entries via the concatenation mechanism:

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

** With Overrides
:header-args:R+ :cache no

Similarly, each source block can contain overrides, as well.

I am constantly referring to https://org-babel.readthedocs.io/en/latest/header-args/ to aid in my babel quests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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