我有一个代码块和一个简单的命令:
#+begin_src R :results output graphics :exports results :file a.png
print(qplot(a,binwidth=1)+opts(title="graph title")+scale_x_continuous("axis lable")+scale_y_continuous(formatter="comma"))
#+end_src我在这个会话的前一个块中加载了ggplot2,当我执行C-c C-c来执行该块时,它工作得很好。
当我尝试使用C-c C-e h或C-c C-e P导出或发布文件时,它会写入一个长度为0的a.png。
以下是此文件开头的一些#+行:
#+OPTIONS: H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
#+INFOJS_OPT: view:info toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js
#+EXPORT_SELECT_TAGS: export
#+EXPORT_EXCLUDE_TAGS: noexport
#+BABEL: :session *R* :cache yes :exports both :tangle yes我在XP64系统和“组织模式7.5版”上运行"GNU Emacs23.3.1 (i386-mingw-nt5.2.3790) of 2011-03-10 on 3249CTO“。
我遗漏了什么?我在搜索Stack Overflow、组织模式邮件列表、手册或Google时都没有找到答案。
今天早上我尝试了一个简单的可执行文件:
#+TITLE: test.org
#+AUTHOR:
#+EMAIL: me
#+DATE: 2012-03-01 Thu
#+DESCRIPTION:
#+KEYWORDS:
#+LANGUAGE: en
#+OPTIONS: H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
#+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js
#+EXPORT_SELECT_TAGS: export
#+EXPORT_EXCLUDE_TAGS: noexport
#+LINK_UP:
#+LINK_HOME:
#+XSLT:
#+BABEL: :session *R* :cache yes :exports both :tangle yes
* Test of R
#+begin_src R :results output :export both
summary(rnorm(25))
#+end_src
#+results:
* Test of ggplot2
#+begin_src R :results output graphics :exports results :file testggplot.png
library(ggplot2)
qplot(runif(25))
#+end_src使用C-c C-c可以很好地执行每个代码块。运行C-c C-e h或C-c C-e b将其导出为HTML会给出一个很大的问题:它用内容写入文件testggplot.png
stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.我的猜测是:我在上面得到了一个长度为0的.png文件,因为它不需要编写错误消息。
如果我首先运行C-c C-c,我会在.org文件中得到一个#+results[部分,其中包含一个到testggplot.png的链接。如果打开iimage-mode,我可以在.org文件中看到图形。
如果我接着运行C-c C-e h,我会得到一个带有图形的有效的超文本标记语言文件。
这(或ECM)是否提供了任何线索,可以告诉我应该做什么(除了首先在每个代码块上运行C-c C-c之外)?
更新2:也许HTML org-mode产生的代码片段提供了洞察力。
如果我先运行C-c C-c,这样图形文件已经被写入,那么我会得到
<div id="outline-container-2" class="outline-2">
<h2 id="sec-2"><span class="section-number-2">2</span> Test of ggplot2 </h2>
<div class="outline-text-2" id="text-2">
<p>
<img src="testggplot.png" alt="testggplot.png" />
</p>
</div>
</div>如果我没有先创建文件,那么我会得到
<div id="outline-container-2" class="outline-2">
<h2 id="sec-2"><span class="section-number-2">2</span> Test of ggplot2 </h2>
<div class="outline-text-2" id="text-2">
<pre class="example">
testggplot.png
</pre>
</div>
</div>唯一的区别似乎在于它是将文件名作为文本包装在<pre>块中,还是将其包装为图像。当然,在第一种情况下,它也无法写入.png文件。
发布于 2012-03-02 06:14:54
我对您的test.org示例没有任何问题。
首先,您使用的是相当旧的org-mode版本。我的版本是7.8...(组织模式版本7.8.03 (release_7.8.03.484.ge4ac3))。
其次,请注意设置(缓冲区范围的)头参数的语法已经改变。它不再是#+BABEL等。更多信息请参见"Header arguments in Org mode properties“。在您的情况下,它将看起来像
# Babel settings
#+PROPERTY: session *R*
#+PROPERTY: cache yes
#+PROPERTY: exports both
#+PROPERTY: tangle yeshttps://stackoverflow.com/questions/9508888
复制相似问题