0

I'm stumped as to why I can no longer export an org-babel file with R code chunks and can not work out where the error is cropping up.

A simple example that doesn't include the graph...

#+STARTUP: align
#+FILENAME: dummy.R
#+TITLE: A test
#+PROPERTY: header-args:R :session *test-R*
#+PROPERTY: header-args:R :cache no
#+PROPERTY: header-args:R :width 1024
#+PROPERTY: header-args:R :height 768
#+PROPERTY: header-args:R :tangle yes

#+begin_src R :session *test-R* :eval yes :exports none :results output silent
  library(dplyr)
  library(ggplot2)
#+end_src

#+begin_src R :session *test-R* :eval yes :exports none
  # results :width 1024 :height 768 :results output graphics file :file ~/tmp/test.png
  some_data <- tibble(x = rnorm(10000))
  some_data %>% ggplot(aes(x)) + geom_histogram()
 #+end_src

If I switch to trying to include the graphs by modifying the :exports argument and including some additional info...

#+STARTUP: align
#+FILENAME: dummy.R
#+TITLE: A test
#+PROPERTY: header-args:R :session *test-R*
#+PROPERTY: header-args:R :cache no
#+PROPERTY: header-args:R :width 1024
#+PROPERTY: header-args:R :height 768
#+PROPERTY: header-args:R :tangle yes

#+begin_src R :session *test-R* :eval yes :exports none :results output silent
  library(dplyr)
  library(ggplot2)
#+end_src

#+begin_src R :session *test-R* :eval yes :exports results :width 1024 :height 768 :results output graphics file :file ~/tmp/test.png
  some_data <- tibble(x = rnorm(10000))
  some_data %>% ggplot(aes(x)) + geom_histogram()
 #+end_src

On trying to export I'm informed Wrong type argument: stringp, (:session . "*org-R*") which is confusing since I set the :session *test-R* in the #+PROPERTY: header-args:R and explicitly for each code block.

I don't understand where or why this fails (it worked previously) as I've not updated Emacs (27.2) or org-mode (9.4.6), and do not know how to debug this further.

EDIT : debugger information...

Debugger entered--Lisp error: (wrong-type-argument stringp (:session . "*org-R*"))
  #f(compiled-function (a b) #<bytecode 0x1564bcd7f615>)((:tangle . "yes") ((:session . "*org-R*") (:cache . "yes")))
  sort(((:colname-names) (:rowname-names) (:result-params "replace" "output" "graphics" "file") (:result-type . output) (:results . "replace output graphics file") (:exports . "results") ((:AUTHOR . "Neil Shephard") (:EMAIL . "nshephard@gmail.com"))) #f(compiled-function (a b) #<bytecode 0x1564bcd7f615>))
  org-babel-sha1-hash(("R" "some_data <- tibble(x = rnorm(10000))\nsome_data %>..." ((:colname-names) (:rowname-names) (:result-params "replace" "output" "graphics" "file") (:result-type . output) (:results . "replace output graphics file") (:exports . "results") ((:AUTHOR . "Neil Shephard") (:EMAIL . "nshephard@gmail.com")) (:session . "none") (:cache . "no") (:noweb . "no") (:hlines . "no") ((:session . "*org-R*") (:cache . "yes")) (:tangle . "yes") (:eval . "yes") (:file . "~/tmp/test.png")) "" nil 249 "(ref:%s)") :export)
  org-babel-exp-src-block()
  org-babel-exp-process-buffer()
  org-export-as(html nil nil nil (:output-file "dummy.html"))
  org-export-to-file(html "dummy.html" nil nil nil nil nil)
  org-html-export-to-html(nil nil nil nil)
  org-export-dispatch(nil)
  funcall-interactively(org-export-dispatch nil)
  call-interactively(org-export-dispatch nil nil)
  command-execute(org-export-dispatch)

I see there is some reference to f(compiled-function (a b)... that includes ...((:session . "*org-R*") (:cache . "yes"))but this differs from the settings I've put in the #+PROPERTY: header-args:R

2
  • FWIW, I cannot reproduce the problem with Org mode version 9.5.1 (release_9.5.1-279-g8908fb). Is there a buffer named *org-R* at all? That seems to be some kind of default session name, but that is not the case in the current code, where the default session name is just *R* (as it is in 9.4.6 as well). And I cannot reproduce it with 9.4.6 either. Can you reproduce it if you start emacs with emacs -q, thereby bypassing your init file? It seems to me that your emacs session is curdled for some reason.
    – NickD
    Dec 30 '21 at 3:56
  • 1
    Thanks, no *org-R* buffers running, as usual an emacs -q session worked ok, which as you pointed out meant an error in my configuration. I tracked it down to having tried to add defaults to org-babel-default-header-args:R which I mistakenly thought would only apply when creating a new file (but that is what skeletons are for and I've already defined some of those). The problem, as is often the case with me, sits between the keyboard and the screen. Thanks for your assistance @NickD
    – slackline
    Dec 30 '21 at 10:49

Your Answer

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

Browse other questions tagged or ask your own question.