Using R with Org-babel

to export a graph created by R, use the following line to start the R code:

#+begin_src R :results graphics :file lightning.png :exports both

Parameters explained:

  • :results graphics exports the results as a graphics file.
  • :file lightning.png exports the graph to a file named lightning.png
  • :exports both exports both the code and the results

to end the R code use the following line

#+end_src

R Emacs Tips

M-x R

type M-x R to start the inferior R process in an emacs buffer

History

if you start R-mode in the same directory each time and save the session at the end of your session, then your history and session variables will be preserved between sessions.