【问题标题】:R Not Outputting Graphs in Org BabelR没有在Org Babel中输出图表
【发布时间】:2019-12-18 19:34:48
【问题描述】:

我已经尝试了此页面中的所有四个源块:https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.html

* does /not/ produce a file
#+begin_src R :file 1.png :results value graphics
library(lattice)
xyplot(1:10 ~ 1:10)
#+end_src
* does produce a file, by printing object
#+begin_src R :file 2.png :results value graphics
library(lattice)
print(xyplot(1:10 ~ 1:10))
#+end_src
* does produce a file, by using :results output
#+begin_src R :file 3.png :results output graphics
library(lattice)
xyplot(1:10 ~ 1:10)
#+end_src
* does produce a file, by evaluating in :session
#+begin_src R :file 4.png :session :results graphics
library(lattice)
xyplot(1:10 ~ 1:10)
#+end_src

尽管图像仍然保存为 1.png、2.png 等,但它们都没有输出任何内容。

R 肯定是启用的,因为我已经将它用于不需要可视化的其他事情。

【问题讨论】:

    标签: r org-mode org-babel


    【解决方案1】:

    所以我遇到了这个确切的问题并且非常令人沮丧,malcook 的回答基本上解决了它,在 9.3 更新中对 org-mode 进行了重大更改,基本上现在标题必须包含 :results output graphics file 而之前是 @ 987654324@ 不是必需的,org-mode 9.3.2 中的工作示例:

    #+BEGIN_SRC R :exports both :results output graphics file :file Example9832.png
      library(tidyverse)
      mtcars <- as_tibble(mtcars)
      myplot <-  ggplot(mtcars, aes(x = disp, y = mpg, col = hp, shape = as.factor(cyl))) +
        geom_point() +
        theme_classic() +
        labs(col = "HorsePower", shape = "Cylinders")
      myplot
    #+END_SRC
    

    这应该给出这样的输出:

    Org-Babel Ggplot2 example

    【讨论】:

      【解决方案2】:

      请运行 meta-x org-version。

      是 9.3 吗?

      然后看:Version 9.3 Incompatible changes

      :file header 参数不再假定“file” :results “file” :results 值现在对于返回链接的代码块是强制性的 文件。 :file 或 :file-ext 标头参数不再暗示“文件” 结果是预期的。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多