How can I get a graph back in my org-babel results for R code?
#+BEGIN_SRC R :results output latex boxplot(islands) #+END_SRC
Islands is a baked in dataset for R.
Do you do it with
and org-auto-load-images = T in your .emacs?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
You're very close! Two changes:
For the R code, you'll need a few more headers:
#+BEGIN_SRC R :results output graphics :file test.png library("ggplot2") ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, color = Species)) + geom_point() #+END_SRC
(Note that the headers change slightly depending on whether you want to use base R, as in your example, or something like ggplot2, as in mine. See the docs here for more exposition on this. TL;DR: include
output if you want to use
ggplot2 et al.)
To display the image, you've got a couple choices:
org-toggle-inline-imageswill switch inline image display on and off
org-startup-with-inline-imagesis a variable which can be set in your config files (
.emacs.d/ whathaveyou). If non-nil, images will be shown by default on buffer load.
Also useful is
org-redisplay-inline-images, for refreshing an image that's changed on disk if org doesn't auto-reload it.