From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Leha Subject: Re: Babel and R: Call code block and output plot Date: Mon, 27 Jul 2015 22:19:29 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJpoP-0003tp-1C for emacs-orgmode@gnu.org; Mon, 27 Jul 2015 17:19:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZJpoK-00069a-Rk for emacs-orgmode@gnu.org; Mon, 27 Jul 2015 17:19:52 -0400 Received: from plane.gmane.org ([80.91.229.3]:40441) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZJpoK-000698-Ky for emacs-orgmode@gnu.org; Mon, 27 Jul 2015 17:19:48 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZJpoG-0006QC-2X for emacs-orgmode@gnu.org; Mon, 27 Jul 2015 23:19:44 +0200 Received: from cpc33-cmbg15-2-0-cust4.5-4.cable.virginm.net ([81.102.136.5]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 27 Jul 2015 23:19:44 +0200 Received: from andreas.leha by cpc33-cmbg15-2-0-cust4.5-4.cable.virginm.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 27 Jul 2015 23:19:44 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi Stefan, Stefan Nobis writes: > Hi. > > I'm playing a little bit with R code blocks in babel and calling them > in different parts of my document (e.g. showing output in the main > part and the code in the appendix). > > With most code blocks (e.g. setting some variables or outputting a > LaTeX table with xtable) this works as expected (thanks to all working > on this; its really great). > > Now I wanted to show a plot, but the associated code should also be > shown in the appendix. In this case CALL seems not to work (not plot > file is created or its empty). > > Here is a small example of what I'm trying to achieve: > > #+TITLE: Plotting Test > #+OPTIONS: author:nil date:nil email:nil toc:nil > #+CREATOR: Emacs 24.5.1 (Org mode 8.2.10) > #+STARTUP: showall > #+PROPERTY: session *R* > #+PROPERTY: exports results > > * Main Part > > Here I want to show some plot: > > #+CALL: myplot[:exports results]() > > * Appendix > > Here the code of the plot should be shown: > > #+NAME: myplot > #+BEGIN_SRC R :results output graphics :exports code :file my-plot.pdf > hist(rnorm(50)) > #+END_SRC > > Any ideas what I'm doing wrong or how to better achieve my goal? You still have to specify the format of the results of the #+CALL line, as in #+CALL: myplot[:exports results]() :results file BTW, I also think the 'output' in :results is spurious. This work for me: --8<---------------cut here---------------start------------->8--- #+TITLE: Plotting Test #+OPTIONS: author:nil date:nil email:nil toc:nil #+CREATOR: Emacs 24.5.1 (Org mode 8.2.10) #+STARTUP: showall #+PROPERTY: session *R* #+PROPERTY: exports results * Main Part Here I want to show some plot: #+CALL: myplot[:exports results]() :results file #+results: [[file:my-plot.pdf]] * Appendix Here the code of the plot should be shown: #+NAME: myplot #+BEGIN_SRC R :results graphics :exports code :file my-plot.pdf hist(rnorm(50)) #+END_SRC --8<---------------cut here---------------end--------------->8--- Best, Andreas