Reputation: 505
I have the following code block.
#+begin_src R :file 5.png :session :results graphics file
library(ggplot2)
ggplot(mtcars, aes(x = cyl, y = wt)) + geom_point()
#+end_src
When I run pdflatex on it, it prints the code, which I don't want, and doesn't insert the file, which I want. What do I need to do?
I thought this seemed relevant, org mode not producing R plots, but it doesn't work for me. And the examples here, https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.html, don't seem to work either for me.
Upvotes: 0
Views: 266
Reputation: 727
I think you are missing :exports results
, so the whole file is:
#+BEGIN_SRC R :file 5.png :session :results graphics file :exports results
library(ggplot2)
ggplot(mtcars, aes(x = cyl, y = wt)) + geom_point()
#+end_src
When I export this (org-export-dispatch
bound by default to C-c C-e
, then choose l
for Latex
, then o
for As PDF file and open
), I see a pdf with the plot.
Upvotes: 1