From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: [Orgmode] Re: Can't import a remote reference to a whole column in orgtbl Date: Tue, 01 Nov 2011 17:23:00 -0400 Message-ID: <8278.1320182580@alphaville.americas.hpqcorp.net> References: <82e274891002251643k327135aajea270914244abff7@mail.gmail.com> <82e274891002251654s643e8003pdb2b3db669d5528b@mail.gmail.com> <83d3zs8hya.fsf@yahoo.it> <789851DE-3D35-4623-AB0A-E4168A5A178E@gmail.com> <4BB8E250.8090404@alumni.ethz.ch> <77A0A719-665A-493B-9FFA-7FC17F7EA485@gmail.com> <4BB97F0C.6080009@alumni.ethz.ch> <4BBA2B48.4080801@alumni.ethz.ch> <78F3D228-8E40-49AC-A58C-510AB9031203@gmail.com> <4BBCE315.5020200@alumni.ethz.ch> Reply-To: nicholas.dokos@hp.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:54842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLLnU-0002bw-SC for emacs-orgmode@gnu.org; Tue, 01 Nov 2011 17:23:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RLLnT-00030y-1P for emacs-orgmode@gnu.org; Tue, 01 Nov 2011 17:23:04 -0400 Received: from g1t0026.austin.hp.com ([15.216.28.33]:26420) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLLnS-00030r-R8 for emacs-orgmode@gnu.org; Tue, 01 Nov 2011 17:23:03 -0400 In-Reply-To: Message from Michael Brand of "Wed\, 07 Apr 2010 21\:55\:01 +0200." <4BBCE315.5020200@alumni.ethz.ch> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Michael Brand Cc: nicholas.dokos@hp.com, Org-Mode List , Carsten Dominik [Aaaargh: premature communication - apologies to all and let me try again] Michael Brand 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? >=20 > 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 numbe= ring > http://orgmode.org/worg/org-hacks.php#sec-17.2 >=20 > 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 >=20 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 coordi= nates" that got incorporated into org. That allowed Michael to do a table transpos= ition 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 mig= ht 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 t= he right dimensions, delete any separator lines manually and then apply a sequ= ence of (identical) formulas, one for each column in the destination table, that populates the column from the corresponding row of the source table, then a= dd 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:=20 | year | min | avg | max | | 2004 | 401 | 402 | 403 | | 2005 | 501 | 502 | 503 | | 2006 | 601 | 602 | 603 | | 2007 | 701 | 702 | 703 | | 2008 | 801 | 802 | 803 | | 2009 | 901 | 902 | 903 | #+TBLFM: $1 =3D remote(FOO, @$#$@#) :: $2 =3D remote(FOO, @$#$@#) :: $3 =3D= remote(FOO, @$#$@#) :: $4 =3D remote(FOO, @$#$@#) And voil=C3=A0 - transposition. As Carsten notes however, this is kind of hard to do and at the time there = was no way to condense the multiple formulas into one; but ranges on the LHS ha= ve now been added to org and can do just that: | year | min | avg | max | | 2004 | 401 | 402 | 403 | | 2005 | 501 | 502 | 503 | | 2006 | 601 | 602 | 603 | | 2007 | 701 | 702 | 703 | | 2008 | 801 | 802 | 803 | | 2009 | 901 | 902 | 903 | #+TBLFM: @1$1..@>$> =3D remote(FOO, @$#$@#) Nick Footnotes: [fn:1] Note the order - not sure why org-table-create wants the dimensions = in the "opposite" order.