From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Hendy Subject: Re: Using cat() with R prints R session prompt (>) in results block Date: Sat, 23 Mar 2013 20:32:24 -0500 Message-ID: References: <87vc8hpwvz.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([208.118.235.92]:46509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJZnO-00015M-PQ for emacs-orgmode@gnu.org; Sat, 23 Mar 2013 21:32:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UJZnN-00017D-Mk for emacs-orgmode@gnu.org; Sat, 23 Mar 2013 21:32:26 -0400 Received: from mail-la0-x229.google.com ([2a00:1450:4010:c03::229]:45467) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJZnN-000178-Ew for emacs-orgmode@gnu.org; Sat, 23 Mar 2013 21:32:25 -0400 Received: by mail-la0-f41.google.com with SMTP id fo12so9491223lab.0 for ; Sat, 23 Mar 2013 18:32:24 -0700 (PDT) In-Reply-To: <87vc8hpwvz.fsf@gmail.com> 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: Eric Schulte Cc: emacs-orgmode On Sat, Mar 23, 2013 at 5:20 PM, Eric Schulte wrote: > [...] >> I'm getting the > prompt from my R session output >> with the cat() command. For example: >> >> #+name: test >> #+begin_src R :session r :results output raw :exports results >> >> cat(paste("#+end_center")) >> cat("\n") >> >> #+end_src >> >> #+RESULTS: test >> #+end_center> >> >> How do I stop that? >> >> As a side note... if I remove cat("\n"), nothing gets put into the >> #+results block -- it's just empty. I don't understand why. >> > > Hi John, > > This seems to be related to newlines and the parsing of session output. > Results aren't noticed without a newline, and when intermediately > printed results do not end in a newline, the prompt is pasted along with > the results. > > If we look at the R session buffer, the cause of this bad behavior can > be seen. > > ,----[ESS buffer] > | > cat(paste("#+end_center")) > | cat("\n") > | 'org_babel_R_eoe' > | cat(paste("#+end_center")) > | #+end_center> cat("\n") > | > | > | > 'org_babel_R_eoe' > | [1] "org_babel_R_eoe" > `---- > > I'm not sure that we can (robustly and reasonably) distinguish the R > prompt from R process output when the prompt does not appear at the > start of a line. Perhaps ESS could mark R prompts with a special text > property which would make this much easier from the Org-mode side? > So babel filters out the ">" prompt if it's the first character? Makes sense? > Is it possible simply to ensure that code block output lines end in > newlines? As in, instead of =cat(paste("#+end_center"))= use =cat(paste("#+end_center \n"))= ? If so, absolutely. I think for some reason I had trouble with this once before, but I don't recall specifics. I'll give it a try on Monday and confirm this works. If so, perhaps I could add a tidbit in ob-R-doc about doing this when not simply including a single file for export output. Thanks for chiming in, John > > Cheers, > > -- > Eric Schulte > http://cs.unm.edu/~eschulte