* feature request: transpose a table
@ 2009-09-10 21:59 zwz
0 siblings, 0 replies; 3+ messages in thread
From: zwz @ 2009-09-10 21:59 UTC (permalink / raw)
To: emacs-orgmode
Hi,
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.
I also wonder how do you guys draw multiple lines in one image, since
here there are multiple inds.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: feature request: transpose a table
@ 2010-04-07 19:52 Michael Brand
2010-04-07 22:57 ` Thomas S. Dye
0 siblings, 1 reply; 3+ messages in thread
From: Michael Brand @ 2010-04-07 19:52 UTC (permalink / raw)
To: zwz; +Cc: Eric S Fraga, Org Mode
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: feature request: transpose a table
2010-04-07 19:52 Michael Brand
@ 2010-04-07 22:57 ` Thomas S. Dye
0 siblings, 0 replies; 3+ messages in thread
From: Thomas S. Dye @ 2010-04-07 22:57 UTC (permalink / raw)
To: Michael Brand; +Cc: Eric S Fraga, Org Mode, zwz
On Apr 7, 2010, at 9:52 AM, Michael Brand wrote:
> 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
Aloha all,
There is also this code for transposing a table in the Library of Babel:
--------
* Table/Matrix manipulation
Elegant lisp code for transposing a matrix.
#+tblname: transpose-example
| 1 | 2 | 3 |
| 4 | 5 | 6 |
#+srcname: transpose
#+begin_src emacs-lisp :var table=transpose-example
(apply #'mapcar* #'list table)
#+end_src
#+resname:
| 1 | 4 |
| 2 | 5 |
| 3 | 6 |
----------
All the best,
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-04-07 22:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-10 21:59 feature request: transpose a table zwz
-- strict thread matches above, loose matches on Subject: below --
2010-04-07 19:52 Michael Brand
2010-04-07 22:57 ` Thomas S. Dye
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).