all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [babel] RFC: column and row names in babel tables
@ 2010-04-10  0:03 Dan Davison
  2010-04-11 20:30 ` Taru Karttunen
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Davison @ 2010-04-10  0:03 UTC (permalink / raw)
  To: emacs org-mode mailing list

If others would like to comment on this proposal that would be really
helpful (warning: probably not fun reading):

The question is: how do we map between org tables with hline separators
and tabular data structures in babel languages (some of which have
internal concepts of "column names" and "row names")? In particular, one
might commonly use an hline in org to form "column names":

| column | names    |
|--------+----------|
| table  | contents |

* Example tables
#+tblname: A
| a | b | c |
| d | e | f |
| g | h | i |

#+tblname: B
| a | b | c |
|---+---+---|
| d | e | f |
| g | h | i |

#+tblname: C
| a | b | c |
|---+---+---|
| d | e | f |
|---+---+---|
| g | h | i |


- Terminology ::

  - Table B above has "column names" and therefore one "hline". Table
    A has neither. Table C has "column names" and two "hlines".

  - For the purposes of this discussion, there are no such things as
    "row names" in an Org table.

- What will we do with hlines ::

  Currently, all languages other than R fail with hlines present.

  New behaviour: by default all languages will *drop all hlines* from
  tables in input. We shall make no attempt to reinstate hlines in the
  output[1] *Do we want some way for the user to control hlines in the
  output?*
  
  This means that if a table has column names, those column names will
  be passed to the language as an ordinary first row of the table.

  This example shows loss of all hlines by default:

#+begin_src python :var tab=C
tab
#+end_src

#+results:
| a | b | c |
| d | e | f |
| g | h | i |

  
- :colnames header argument ::
  
  This argument will be used to say: "The first row of this input
  table contains column names." There are two cases:

  In both cases, to start off with we *drop all hlines* and *omit the
  first row*. Therefore, row i in the org table will be row i-1 in the
  language. The difference is:

  1. Language does not support column names for tabular data
     structures (most languages)

     When we output a table we reinstate the first row as column names
     with an hline, *if* the output number of columns is the same as
     the input. *Do you agree?*

  2. Language supports column names (R)
  
     The input R object is created with the first row as column names,
     and the column names of the output object are exported back to
     org, and an hline is reinstated.

This example shows preservation of colnames and loss of second hline:

#+begin_src python :var tab=C :colnames yes
tab
#+end_src

#+results:
| a | b | c |
|---+---+---|
| d | e | f |
| g | h | i |

- :rownames header argument ::
  
  This is analogous to :colnames
  
  This argument will be used to say: "The first column of this input
  table contains row names." There are two cases. In both cases we
  *omit the first column*, therefore column j in the org table will be
  column j-1 in the language.
  
  1. Language does not support row names for tabular data structures
     (most languages)

     We attempt to *reinstate row names* if number of output rows is
     the same as input.

  2. Language supports rownames (R)
     
     The first column is used as the object rownames. The output
     object rownames are exported to Org and become the first column
     of the output org table.

     This is largely implemented already by a patch by Julien Barnier.

Dan

* Footnotes

[1] Because the output table is not necessarily "the same table" as
the input table.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [babel] RFC: column and row names in babel tables
  2010-04-10  0:03 [babel] RFC: column and row names in babel tables Dan Davison
@ 2010-04-11 20:30 ` Taru Karttunen
  2010-04-11 21:09   ` Dan Davison
  0 siblings, 1 reply; 3+ messages in thread
From: Taru Karttunen @ 2010-04-11 20:30 UTC (permalink / raw)
  To: Dan Davison, emacs org-mode mailing list

On Fri, 09 Apr 2010 20:03:55 -0400, Dan Davison <davison@stats.ox.ac.uk> wrote:
>   New behaviour: by default all languages will *drop all hlines* from
>   tables in input. We shall make no attempt to reinstate hlines in the
>   output[1] *Do we want some way for the user to control hlines in the
>   output?*

Why not an empty row?

| 1 | 2 | 3 |
|---+---+---|
| 4 | 5 | 6 |

would become: [[1,2,3], [], [4,5,6]].

- Taru Karttunen

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [babel] RFC: column and row names in babel tables
  2010-04-11 20:30 ` Taru Karttunen
@ 2010-04-11 21:09   ` Dan Davison
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Davison @ 2010-04-11 21:09 UTC (permalink / raw)
  To: Taru Karttunen; +Cc: emacs org-mode mailing list

Taru Karttunen <taruti@taruti.net> writes:

> On Fri, 09 Apr 2010 20:03:55 -0400, Dan Davison <davison@stats.ox.ac.uk> wrote:
>>   New behaviour: by default all languages will *drop all hlines* from
>>   tables in input. We shall make no attempt to reinstate hlines in the
>>   output[1] *Do we want some way for the user to control hlines in the
>>   output?*

Hi Taru,

Thanks for responding.

>
> Why not an empty row?
>
> | 1 | 2 | 3 |
> |---+---+---|
> | 4 | 5 | 6 |
>
> would become: [[1,2,3], [], [4,5,6]].

One problem is that in some languages, org tables are converted into a
matrix-like data structure, not simply a list-of-lists. An example is R
(and I think also gnuplot). So in those languages, all rows must be the
same length. Also, I believe that hlines are ignored when computing
indexes in Org table formulas, so I thought that omitting hlines would
make indexing in babel languages more consistent with indexing in org.

Dan


>
> - Taru Karttunen
>
>
> _______________________________________________
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-04-11 21:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-10  0:03 [babel] RFC: column and row names in babel tables Dan Davison
2010-04-11 20:30 ` Taru Karttunen
2010-04-11 21:09   ` Dan Davison

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.