From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Hajage Subject: Re: Babel: interweaving code and results? Date: Wed, 18 Aug 2010 16:57:28 +0200 Message-ID: References: <4C6BDCE3.9010903@ccbr.umn.edu> <87k4no0ye5.fsf@stats.ox.ac.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0589109119==" Return-path: Received: from [140.186.70.92] (port=40342 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Olk5P-0008CE-6U for emacs-orgmode@gnu.org; Wed, 18 Aug 2010 10:57:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Olk5N-0007lU-MF for emacs-orgmode@gnu.org; Wed, 18 Aug 2010 10:57:51 -0400 Received: from mail-fx0-f41.google.com ([209.85.161.41]:33952) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Olk5N-0007lJ-Ej for emacs-orgmode@gnu.org; Wed, 18 Aug 2010 10:57:49 -0400 Received: by fxm3 with SMTP id 3so350455fxm.0 for ; Wed, 18 Aug 2010 07:57:48 -0700 (PDT) In-Reply-To: <87k4no0ye5.fsf@stats.ox.ac.uk> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Dan Davison Cc: emacs-orgmode@gnu.org --===============0589109119== Content-Type: multipart/alternative; boundary=001485f5b1ecf8f277048e1a4924 --001485f5b1ecf8f277048e1a4924 Content-Type: text/plain; charset=ISO-8859-1 exactly what I want! But an new option would be greater... Yes, I know about :exports both, but if code and results are interleaved, I don't need to export the code (in my case). That's why I use :exports results. Thank you very much for this. David On Wed, Aug 18, 2010 at 16:49, Dan Davison wrote: > Erik Iverson writes: > > > David, > > > > On 08/18/2010 08:09 AM, David Hajage wrote: > >> Hello, > >> > >> I am back with babel and R with a new question. Is it possible to > >> interweave each line of code with its results? > >> > >> An example to explain what I mean: > >> > >> #+SRCNAME: foo > >> #+BEGIN_SRC R :results output :exports results > >> 2+2 > >> 3+3 > >> #+END_SRC > >> > >> #+results: foo > >> : [1] 4 > >> : [1] 6 > >> > >> When exporting (to html or latex), I would like to print what is going > >> on in the R console. So, I would like: > >> > >> #+results: foo > >> :> 2+2 > >> : [1] 4 > >> :> 3+3 > >> : [1] 6 > >> > >> Is it possible, or eventualy planned for the futur? > > Hi David, > > This is actually quite easy, although I don't think anyone's flagged > this possibility up: just do > > (setq org-babel-R-command "R --silent --no-save") > > (Our default is --slave --no-save) There's an example session below. By > the way, can I just check that you're aware of the ':exports both' > option? That's the canonical Org way of exporting both code and > results. It doesn't interleave them: it's more geared towards 'one code > block <-> one result'. But I understand that there may be situations > where interleaved is desired. > > Erik -- You might well be right that we should add an :interleave option > to modify :results output like this. > > --8<---------------cut here---------------start------------->8--- > #+begin_src emacs-lisp > org-babel-R-command > #+end_src > > #+results: > : R --slave --no-save > > #+begin_src R :results output > 2+2 > 3+3 > #+end_src > > #+results: > : [1] 4 > : [1] 6 > > #+begin_src emacs-lisp > (setq org-babel-R-command "R --silent --no-save") > #+end_src > > #+results: > : R --silent --no-save > > #+begin_src R :results output > 2+2 > 3+3 > #+end_src > > #+results: > : > 2+2 > : [1] 4 > : > 3+3 > : [1] 6 > : > > --8<---------------cut here---------------end--------------->8--- > > [Maybe we can battle that trailing prompt character] > > Dan > > > > > I think I put together a :results weave option a couple > > months ago that did just this. > > > > I'll have to look if I can find it, I'll > > let you know. > > > > _______________________________________________ > > Emacs-orgmode mailing list > > Please use `Reply All' to send replies to the list. > > Emacs-orgmode@gnu.org > > http://lists.gnu.org/mailman/listinfo/emacs-orgmode > --001485f5b1ecf8f277048e1a4924 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable exactly what I want! But an new option would be greater...

Yes, I know about :exports both, but if code and results are interleaved= , I don't need to export the code (in my case). That's why I use :e= xports results.

Thank you very much for this.

David


On Wed, Aug 18, 2010 at 16:49, Dan Davis= on <davison@= stats.ox.ac.uk> wrote:
Erik Iverson <er= iki@ccbr.umn.edu> writes:

> David,
>
> On 08/18/2010 08:09 AM, David Hajage wrote:
>> Hello,
>>
>> I am back with babel and R with a new question. Is it possible to<= br> >> interweave each line of code with its results?
>>
>> An example to explain what I mean:
>>
>> #+SRCNAME: foo
>> #+BEGIN_SRC R :results output :exports results
>> =A0 =A02+2
>> =A0 =A03+3
>> #+END_SRC
>>
>> #+results: foo
>> : [1] 4
>> : [1] 6
>>
>> When exporting (to html or latex), I would like to print what is g= oing
>> on in the R console. So, I would like:
>>
>> #+results: foo
>> :> 2+2
>> : [1] 4
>> :> 3+3
>> : [1] 6
>>
>> Is it possible, or eventualy planned for the futur?

Hi David,

This is actually quite easy, although I don't think anyone's flagge= d
this possibility up: just do

(setq org-babel-R-command "R --silent --no-save")

(Our default is --slave --no-save) There's an example session below. By=
the way, can I just check that you're aware of the ':exports both&#= 39;
option? That's the canonical Org way of exporting both code and
results. It doesn't interleave them: it's more geared towards '= one code
block <-> one result'. But I understand that there may be situati= ons
where interleaved is desired.

Erik -- You might well be right that we should add an :interleave option to modify :results output like this.

--8<---------------cut here---------------start------------->8---
#+begin_src emacs-lisp
org-babel-R-command
#+end_src

#+results:
: R --slave --no-save

#+begin_src R :results output
2+2
3+3
#+end_src

#+results:
: [1] 4
: [1] 6

#+begin_src emacs-lisp
(setq org-babel-R-command "R --silent --no-save")
#+end_src

#+results:
: R --silent --no-save

#+begin_src R :results output
2+2
3+3
#+end_src

#+results:
: > 2+2
: [1] 4
: > 3+3
: [1] 6
: >
--8<---------------cut here---------------end--------------->8---

[Maybe we can battle that trailing prompt character]

Dan

>
> I think I put together a :results weave option a couple
> months ago that did just this.
>
> I'll have to look if I can find it, I'll
> let you know.
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

--001485f5b1ecf8f277048e1a4924-- --===============0589109119== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --===============0589109119==--