emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <nicholas.dokos@hp.com>
To: Michael Brand <michael.brand@alumni.ethz.ch>
Cc: nicholas.dokos@hp.com, Org-Mode List <emacs-orgmode@gnu.org>,
	Carsten Dominik <carsten.dominik@gmail.com>
Subject: Re: [Orgmode] Re: Can't import a remote reference to a whole column in orgtbl
Date: Tue, 01 Nov 2011 17:14:45 -0400	[thread overview]
Message-ID: <8038.1320182085@alphaville.americas.hpqcorp.net> (raw)
In-Reply-To: Message from Michael Brand <michael.brand@alumni.ethz.ch> of "Wed, 07 Apr 2010 21:55:01 +0200." <4BBCE315.5020200@alumni.ethz.ch>

Michael Brand <michael.brand@alumni.ethz.ch> wrote:

> Carsten Dominik wrote:
> > this is neat, but still kind of hard to do, because you have to put
> > all these formulas there by hand.  I am skipping this for the manual
> > - maybe you'd like to put this into org-hacks, or into the FAQ on
> > Worg?
> 
> Ok, I have put it into Worg org-hacks.org:
> http://orgmode.org/worg/org-hacks.php
> in the section `Field coordinates in formulas', currently with this numbering
> http://orgmode.org/worg/org-hacks.php#sec-17.2
> 
> And only now I have seen and answered this thread:
> `feature request: transpose a table'
> started here
> http://thread.gmane.org/gmane.emacs.orgmode/17453
> and continued here
> http://thread.gmane.org/gmane.emacs.orgmode/23809
> 

Since this is  a reply to an old thread, let me set some context: there was a flurry
of activity about transposing a table about 1.5 years ago - in addition to the two
threads above, there was

	http://thread.gmane.org/gmane.emacs.orgmode/22610

	http://thread.gmane.org/gmane.emacs.orgmode/22930

The latter contains a patch by Michael Brand that  introduced "field coordinates"
that got incorporated into org. That allowed Michael to do a table transposition
that he also added to org-hacks (but the section number has changed - it is at

          http://orgmode.org/worg/org-hacks.html#sec-1-3-5

currently).

There were various other solutions too using lisp (by Tom Dye and Juan
Pechiar: iiuc, both of these were based on library-of-babel code), that might
be more efficient than Michael's solution (Carsten warns explicitly about
the inefficiency somewhere).

But Michael's solution is clever: the idea is to create an empty table of the
right dimensions, delete any separator lines manually and then apply a sequence
of (identical) formulas, one for each column in the destination table, that
populates the column from the corresponding row of the source table, then add
separator lines back manually. To simplify the discussion, here's an example
without separators:

#+TBLNAME: FOO
| year | 2004 | 2005 | 2006 | 2007 | 2008 | 2009 |
| min  |  401 |  501 |  601 |  701 |  801 |  901 |
| avg  |  402 |  502 |  602 |  702 |  802 |  902 |
| max  |  403 |  503 |  603 |  703 |  803 |  903 |

So create a 7x4 table: M-x org-table-create RET 4x7 RET [fn:1]
delete the separator, and apply the formulas: 

|   |   |   |   |
|   |   |   |   |
|   |   |   |   |
|   |   |   |   |
|   |   |   |   |
|   |   |   |   |
|   |   |   |   |
#+TBLFM: $1 = remote(FOO, @$#$@#) :: $2 = remote(FOO, @$#$@#) :: $3 = remote(FOO, @$#$@#) :: $4 = remote(FOO, @$#$@#) ::

Footnotes:

[fn:1] Note the order - not sure why org-table-create wants the dimensions in
the "opposite" order.

  reply	other threads:[~2011-11-01 21:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-26  0:43 Can't import a remote reference to a whole column in orgtbl Ismael Barros²
2010-02-26  0:54 ` Ismael Barros²
2010-02-26  9:27   ` Giovanni Ridolfi
2010-04-03 17:24     ` Ismael Barros²
2010-04-04  6:47       ` Carsten Dominik
2010-04-04 19:02         ` Michael Brand
2010-04-04 20:08           ` Carsten Dominik
2010-04-05  6:11             ` Michael Brand
2010-04-05  6:48               ` Carsten Dominik
2010-04-05 18:26                 ` Michael Brand
2010-04-06  5:15                   ` Carsten Dominik
2010-04-07 19:55                     ` Michael Brand
2011-11-01 21:14                       ` Nick Dokos [this message]
2011-11-01 21:23                       ` [Orgmode] " Nick Dokos

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://www.orgmode.org/

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

  git send-email \
    --in-reply-to=8038.1320182085@alphaville.americas.hpqcorp.net \
    --to=nicholas.dokos@hp.com \
    --cc=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=michael.brand@alumni.ethz.ch \
    /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 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).