问题描述
#+begin_src R :file 5.png :session :results graphics file
library(ggplot2)
ggplot(mtcars,aes(x = cyl,y = wt)) + geom_point()
#+end_src
当我在其上运行pdflatex时,它会打印不需要的代码,并且不会插入我想要的文件。我该怎么办?
我认为这似乎很相关,org mode not producing R plots,但对我而言不起作用。而这里的示例https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.html似乎也不适合我。
解决方法
我认为您缺少:exports results
,所以整个文件是:
#+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
导出时(默认情况下绑定到org-export-dispatch
的{{1}},然后为C-c C-e
选择l
,然后为Latex
选择o
) ,我看到了带有图的pdf。