remacsorg-modeess

Output printed in R code block in org-mode when it shouldn't be


I just upgraded to org 9.3.6 and now my R code blocks aren't working as expected. For example, I have this simple code block,

#+BEGIN_SRC R :session
  mtcars1 <- mtcars
#+END_SRC

I don't expect to see any output as I am saving mtcars as mtcars1, so R shouldn't return anything. However, I see this instead,

enter image description here So, it's running

print(mtcars1)

Why? I don't expect/want to see any output especially with larger data frames as it chokes emacs.


Solution

  • It looks you are using the default value of :results value in your org source header. That can be changed on a case-by-case basis with

    #+begin_src R :session :results output
    mtcars1 <- mtcars 
    #+end_src
    

    or, change the default in your org (or ess/R) init configuration

    (setq org-babel-default-header-args:R '((:results . "output")))