I would like all R src blocks in an org file to use the same session interactively and have included a minimal example below. I added the #+PROPERTY
line as in the manual and ran C-c C-c
as suggested in the related questions to ensure the property takes effect, but it does not seem to work when trying to run src blocks in an interactive manner (i.e. running C-c C-c
on the src blocks)
I am unsure what I am missing or misunderstanding. Is it possible to use file-level properties for interactively running src blocks?
Cannot add general block header arguments in org mode
Org-babel: using properties as code block header arguments, how to make it work?
#+title: Test
#+PROPERTY: header-args:R: :session *R*
Load a library in one block
#+begin_src R
library(dplyr)
#+end_src
#+RESULTS:
| dplyr |
| stats |
| graphics |
| grDevices |
| utils |
| datasets |
| methods |
| base |
Try to use a function from that library in another block
#+begin_src R
mtcars %>% filter(cyl == 4)
#+end_src
Executing the above with C-c C-c fails because it cannot find ~%>%~, so the two src blocks must be running in
independent sessions.
Error in mtcars %>% filter(cyl == 4) : could not find function "%>%"
Calls: <Anonymous> -> <Anonymous>
Execution halted
header-args:R
- see manual :#+PROPERTY: header-args:R :session *R*