Org-mode mailing list
 help / color / Atom feed
From: Michael Brand <michael.brand@alumni.ethz.ch>
To: zwz <zhangweize@gmail.com>
Cc: Eric S Fraga <ucecesf@ucl.ac.uk>, Org Mode <emacs-orgmode@gnu.org>
Subject: Re: feature request: transpose a table
Date: Wed, 07 Apr 2010 21:52:04 +0200
Message-ID: <4BBCE264.3000407@alumni.ethz.ch> (raw)

Hi zwz,

 > I do not know if I can do org-plot on rows instead of columns.
 > But today after I finished a table, I found I have to transpose the
 > table by hand so that I can plot it as I want.
 > Here is original table:
 > |  x  | y  | x  | y  | ... |
 > |-----+----+----+----+-----|
 > |   1 |  2 |  3 |  4 |     |
 > |   5 |  6 |  7 |  8 |     |
 > |   9 |  0 |  1 |  2 |     |
 > | ... |    |    |    |     |
 > And I have to convert it into:
 > |   x | y | x | y | x | y | ... |
 > |-----+---+---+---+---+---+-----|
 > |   1 | 2 | 5 | 6 | 9 | 0 |     |
 > |   3 | 4 | 7 | 8 | 1 | 2 |     |
 > | ... |   |   |   |   |   |     |
 >
 > so that every two columns stand for a line.

If someone had trouble to understand like me first, maybe looking also at the 
last table below with the column groups `<>' could help.

This use case seems quite funny and well suited to be solved with the `field 
coordinates in formulas' for which I proposed a patch some time ago that is 
included in org-mode now. Since org-version 6.35 you could try this hack:

step 1) Remove the header and use column editing from Emacs
http://www.gnu.org/software/emacs/manual/html_node/emacs/Rectangles.html
to change your original version of the table

| x | y | x | y |
|---+---+---+---|
| 1 | 2 | 3 | 4 |
| 5 | 6 | 7 | 8 |
| 9 | 0 | 1 | 2 |

to this 3x2 table with Calc vectors in short notation:

#+TBLNAME: FOO
| [1 2] | [3 4] |
| [5 6] | [7 8] |
| [9 0] | [1 2] |

step 2) Transpose the table like described here
http://orgmode.org/worg/org-hacks.php
in the section `Transpose a table', currently with this numbering
http://orgmode.org/worg/org-hacks.php#sec-17.2.3
to this 2x3 table with the same Calc vectors in the default notation:

| [1, 2] | [5, 6] | [9, 0] |
| [3, 4] | [7, 8] | [1, 2] |
#+TBLFM: $1 = remote(FOO, @$#$@#) :: $2 = remote(FOO, @$#$@#) :: $3 = 
remote(FOO, @$#$@#)

step 3) query-replace `['->`', `]'->`', `,'->`|' and add the header manually 
to get finally this:

|   | x | f.a(x) | x | f.b(x) | x | f.c(x) |
| / | < |      > | < |      > | < |      > |
|---+---+--------+---+--------+---+--------|
|   | 1 |      2 | 5 |      6 | 9 |      0 |
|   | 3 |      4 | 7 |      8 | 1 |      2 |

 > I also wonder how do you guys draw multiple lines in one image, since
 > here there are multiple inds.

I guess you want a xy graph something like this with three lines a, b and c 
for f.a, f.b and f.c:

   f.n(x)
    ^
08 |      b
07 |     b
06 |    b
05 |
04 |  a
03 | a
02 |*c
01 |  ccccc
00 +-------cc--> x
    000000000011
    012345678901

see
http://thread.gmane.org/gmane.emacs.orgmode/21979

I assume that this could be done also with org-babel together with R
http://en.wikipedia.org/wiki/R_%28programming_language%29
possibly even with your original version of the table...

- Michael

             reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-07 19:52 Michael Brand [this message]
2010-04-07 22:57 ` Thomas S. Dye
  -- strict thread matches above, loose matches on Subject: below --
2009-09-10 21:59 zwz

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

  List information: https://orgmode.org

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BBCE264.3000407@alumni.ethz.ch \
    --to=michael.brand@alumni.ethz.ch \
    --cc=emacs-orgmode@gnu.org \
    --cc=ucecesf@ucl.ac.uk \
    --cc=zhangweize@gmail.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

Org-mode mailing list

Archives are clonable:
	git clone --mirror https://orgmode.org/list/0 list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ https://orgmode.org/list \
		emacs-orgmode@gnu.org
	public-inbox-index list

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git