r - R没有在Org Babel中输出图表
问题描述
我已经从这个页面尝试了所有四个源代码块: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 肯定是启用的,因为我已经将它用于不需要可视化的其他事情。
解决方案
所以我遇到了这个确切的问题,非常令人沮丧,malcook 的回答基本上解决了它,org-mode
在 9.3 更新中有一个重大变化,基本上现在标题必须包含:results output graphics file
,而在它file
不是必需的之前,一个工作示例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
这应该给出这样的输出:
推荐阅读
- oauth - Google OAuth 检查用户是否从 Google 注销
- javascript - Expo react native 无法获得奖励 admob 以显示在开发或构建中
- php - 在要邮寄的表格上显示前导零
- javascript - 已分配计算属性,但它没有设置器 - 切换组件
- ios - 在 Xcode 中禁用一些警告
- sql - 编写一个函数或正则表达式,将在 sql 中拆分字符串
- angular - zone.js 将 Angular 6 升级到 7.2 后抛出 404 错误
- java - Java 重复局部变量。难倒
- typescript - 如何使打字稿转译 ES6 类
- node.js - 您好,我想在 gitHub 中部署我的应用程序并在 Heroku 中运行我的应用程序,但我的代码中有一些敏感信息。我现在该怎么办?