From: "Charles C. Berry" <ccberry@ucsd.edu>
To: "Thomas S. Dye" <tsd@tsdye.com>
Cc: emacs-org list <emacs-orgmode@gnu.org>,
eschulte@cs.unm.edu, Kaushal Modi <kaushal.modi@gmail.com>
Subject: Re: Preventing RESULTS from being formatted as org table [ob-awk]
Date: Sun, 12 Jun 2016 14:02:08 -0700 [thread overview]
Message-ID: <alpine.OSX.2.20.1606121302340.831@charles-berrys-macbook.local> (raw)
In-Reply-To: <m260tep5ob.fsf@tsdye.com>
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
next prev parent reply other threads:[~2016-06-12 21:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-12 6:46 Preventing RESULTS from being formatted as org table [ob-awk] Kaushal Modi
2016-06-12 6:59 ` Kaushal Modi
2016-06-12 7:05 ` Kaushal Modi
2016-06-12 16:30 ` Kaushal Modi
2016-06-12 18:22 ` Thomas S. Dye
2016-06-12 18:41 ` Kaushal Modi
2016-06-12 19:29 ` Thomas S. Dye
2016-06-12 21:02 ` Charles C. Berry [this message]
2016-06-13 14:12 ` Kaushal Modi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.OSX.2.20.1606121302340.831@charles-berrys-macbook.local \
--to=ccberry@ucsd.edu \
--cc=emacs-orgmode@gnu.org \
--cc=eschulte@cs.unm.edu \
--cc=kaushal.modi@gmail.com \
--cc=tsd@tsdye.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.