From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: Re: problem with babel and R Date: Tue, 17 Aug 2010 07:57:05 -0600 Message-ID: <87tymtnxzi.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=35103 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OlMfC-0005i9-2t for emacs-orgmode@gnu.org; Tue, 17 Aug 2010 09:57:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OlMfA-0008OA-HY for emacs-orgmode@gnu.org; Tue, 17 Aug 2010 09:57:13 -0400 Received: from mail-pw0-f41.google.com ([209.85.160.41]:51677) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OlMfA-0008Nv-6g for emacs-orgmode@gnu.org; Tue, 17 Aug 2010 09:57:12 -0400 Received: by pwi3 with SMTP id 3so2777442pwi.0 for ; Tue, 17 Aug 2010 06:57:10 -0700 (PDT) In-Reply-To: (David Hajage's message of "Tue, 17 Aug 2010 14:01:03 +0200") 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: David Hajage Cc: emacs-orgmode@gnu.org Hi David, It seems that the problem here is in the ascii package. It is inserting an empty line at the beginning of your table, so that the table is not snugly sitting under the #+results foo tag, because of this the table isn't seen as results and is not replaced -- if you delete that space then re-run the code block you'll notice that the table is replaced. Org-mode is very capable of inserting tabular data into Org-mode documents without using the ascii package. For example the following would be a more idiomatic example of using Org-mode to create a table from R code. --8<---------------cut here---------------start------------->8--- #+begin_src R numbers <- matrix(c(51,43,22,92,28,21,68,22,9),ncol=3,byrow=TRUE) numbers #+end_src #+results: | 51 | 43 | 22 | | 92 | 28 | 21 | | 68 | 22 | 9 | #+begin_src R :colnames yes numbers <- matrix(c(51,43,22,92,28,21,68,22,9),ncol=3,byrow=TRUE) numbers #+end_src #+results: | V1 | V2 | V3 | |----+----+----| | 51 | 43 | 22 | | 92 | 28 | 21 | | 68 | 22 | 9 | --8<---------------cut here---------------end--------------->8--- or applied to your example, the following code block should generate the desired results. --8<---------------cut here---------------start------------->8--- #+srcname: foo #+begin_src R :session *R* head(esoph) #+end_src --8<---------------cut here---------------end--------------->8--- One last small note: the "replace" argument to :results is normally the default value, and doesn't need to be explicitly added (although I can see why you would have added it in this case since it wasn't working as expected). Cheers -- Eric David Hajage writes: > I tried the code with the last development version of org-mode: > > #+srcname: foo > #+begin_src R :session *R* :results output org replace > library(ascii) > options(asciiType = "org") > ascii(head(esoph)) > #+end_src > > #+results: foo > > | | agegp | alcgp | tobgp | ncases | ncontrols | > |---+-------+-----------+----------+--------+-----------| > | 1 | 25-34 | 0-39g/day | 0-9g/day | 0.00 | 40.00 | > | 2 | 25-34 | 0-39g/day | 10-19 | 0.00 | 10.00 | > | 3 | 25-34 | 0-39g/day | 20-29 | 0.00 | 6.00 | > | 4 | 25-34 | 0-39g/day | 30+ | 0.00 | 5.00 | > | 5 | 25-34 | 40-79 | 0-9g/day | 0.00 | 27.00 | > | 6 | 25-34 | 40-79 | 10-19 | 0.00 | 7.00 | > > | | agegp | alcgp | tobgp | ncases | ncontrols | > |---+-------+-----------+----------+--------+-----------| > | 1 | 25-34 | 0-39g/day | 0-9g/day | 0.00 | 40.00 | > | 2 | 25-34 | 0-39g/day | 10-19 | 0.00 | 10.00 | > | 3 | 25-34 | 0-39g/day | 20-29 | 0.00 | 6.00 | > | 4 | 25-34 | 0-39g/day | 30+ | 0.00 | 5.00 | > | 5 | 25-34 | 40-79 | 0-9g/day | 0.00 | 27.00 | > | 6 | 25-34 | 40-79 | 10-19 | 0.00 | 7.00 | > > There is no more ">", but an extra space. > But, the replace option doesn't work: results are still appended. I am not > an org-mode guru (far, far away), but I think this is because when output is > org, there is no indication about the "end" of the results. > > David > > > On Tue, Aug 17, 2010 at 10:17, David Hajage wrote: > >> Hello, >> >> I am trying to use babel with R. Here the code: >> >> #+srcname: foo >> #+begin_src R :session *R* :results output org replace >> library(ascii) >> options(asciiType = "org") >> ascii(head(esoph)) >> #+end_src >> >> #+results: foo >> >> > | | agegp | alcgp | tobgp | ncases | ncontrols | >> |---+-------+-----------+----------+--------+-----------| >> | 1 | 25-34 | 0-39g/day | 0-9g/day | 0.00 | 40.00 | >> | 2 | 25-34 | 0-39g/day | 10-19 | 0.00 | 10.00 | >> | 3 | 25-34 | 0-39g/day | 20-29 | 0.00 | 6.00 | >> | 4 | 25-34 | 0-39g/day | 30+ | 0.00 | 5.00 | >> | 5 | 25-34 | 40-79 | 0-9g/day | 0.00 | 27.00 | >> | 6 | 25-34 | 40-79 | 10-19 | 0.00 | 7.00 | >> >> > | | agegp | alcgp | tobgp | ncases | ncontrols | >> |---+-------+-----------+----------+--------+-----------| >> | 1 | 25-34 | 0-39g/day | 0-9g/day | 0.00 | 40.00 | >> | 2 | 25-34 | 0-39g/day | 10-19 | 0.00 | 10.00 | >> | 3 | 25-34 | 0-39g/day | 20-29 | 0.00 | 6.00 | >> | 4 | 25-34 | 0-39g/day | 30+ | 0.00 | 5.00 | >> | 5 | 25-34 | 40-79 | 0-9g/day | 0.00 | 27.00 | >> | 6 | 25-34 | 40-79 | 10-19 | 0.00 | 7.00 | >> >> With org-mode 7.01g in emacs 23, there is two problems: >> - an extra ">" is added in the first line while output is "org" >> - when I run the code twice, the new results is appended, while I have the >> option "replace". >> >> Is there any problem with my header? >> >> Thank you very much for your help. >> David >> > _______________________________________________ > 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