From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Charles C. Berry" Subject: Re: Preventing RESULTS from being formatted as org table [ob-awk] Date: Sun, 12 Jun 2016 14:02:08 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39921) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCCWO-0002AL-Mt for emacs-orgmode@gnu.org; Sun, 12 Jun 2016 17:02:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCCWJ-0004MW-Nk for emacs-orgmode@gnu.org; Sun, 12 Jun 2016 17:02:15 -0400 Received: from iport-acv4-out.ucsd.edu ([132.239.0.7]:57989) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCCWJ-0004MQ-Ef for emacs-orgmode@gnu.org; Sun, 12 Jun 2016 17:02:11 -0400 In-Reply-To: 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" To: "Thomas S. Dye" Cc: emacs-org list , eschulte@cs.unm.edu, Kaushal Modi On Sun, 12 Jun 2016, Thomas S. Dye wrote: > Aloha Kaushal, > > Kaushal Modi writes: > [deleted] >> >> So what determines if the results should be table formatted or kept verbatim >> (scalar)? >> -- > > I think I'm correct to say that by default a single value result is > output as a scalar, and everything else is converted to an Org mode > table. > TL;DR: That is almost correct. `:post' header arg gives fine control of formatting if needed. `org-babel-insert-result' formats anything that isn't a string or a list using "%S". Then it tries hard to turn a list into a "table". Lists that cannot be made into tables are formatted as strings with "%s\n". However, various languages have their own formatting principles, so what `org-babel-insert-result' gets as the `result' is a bit idiosyncratic. You can get a deeper look at the `result' by pretty printing it with the aid of a :post header arg. Example: #+NAME: I-feel-pretty #+BEGIN_SRC emacs-lisp :results pp *this* #+END_SRC This elisp list is not revised: #+BEGIN_SRC emacs-lisp :post I-feel-pretty '(a b c (d . e)) #+END_SRC #+RESULTS: : (a b c : (d . e)) But R turns its list into an R data.frame and then into a elisp list with an element for each row: #+BEGIN_SRC R :post I-feel-pretty list(a="a",b="b", c="c", d=c("d", "e")) #+END_SRC #+RESULTS: : (("a" "b" "c" "d") : ("a" "b" "c" "e")) HTH, Chuck