emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] Re: Can't import a remote reference to a whole column in o


From: Michael Brand
Subject: Re: [Orgmode] Re: Can't import a remote reference to a whole column in orgtbl
Date: Mon, 05 Apr 2010 20:26:16 +0200
User-agent: Thunderbird 2.0.0.24 (Windows/20100228)

Carsten Dominik wrote:
Sometimes I would like to rewrite the entire table editior for more structural clarity in the sode, so that it would be easier to implement more fancy stuff :-)

Possibly one of these fancy things: Some time ago I thought about transposing a table. But only now I realized that there is no additional implementation required any more because it can be done with the new field coordinates in formulas, address@hidden' and `$#':

For example to transpose this 4x7 table FOO

#+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 |

start with the following 7x4 table without any horizontal line and yet empty and then update the table with the TBLFM that simply takes the row number address@hidden' from the column number `$#' and the column number address@hidden' from the row number address@hidden' for each field.

the transposed copy of FOO:
| 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 = remote(FOO, @address@hidden) :: $2 = remote(FOO, @address@hidden) :: $3 = remote(FOO, @address@hidden) :: $4 = remote(FOO, @address@hidden)

Possible field formulas from the remote table will have to be transferred manually. Since there are no row formulas yet to be transferred to column formulas or vice versa there is not much need yet to transfer formulas automatically.

There could be a hint in the doc somehow like in the following patch. I didn't understand why the `must have at least as many' but anyhow tried to precise, so please check.

======================================================================
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -2065,14 +2065,19 @@ and @code{org-table-current-column}.  Ex

 @example
 if(@@# % 2, $#, string(""))   @r{column number on odd lines only}
-$3 = remote(FOO, @@@@#$2)      @r{copy column 2 from table FOO into}
-                             @r{column 3 of the current table}
+$3 = remote(FOO, @@@@#$2)      @r{copy column 2 from table FOO}
+                             @r{into column 3 of the current table}
+$1 = remote(FOO, @@$#$@@#)     @r{copy row 1 from table FOO transposed}
+                             @r{into column 1 of the current table}
 @end example

address@hidden For the second example, table FOO must have at least as many rows
-as the current table.  address@hidden computation time scales as
-O(N^2) because table FOO is parsed for each field to be copied.} for large
-number of rows.
address@hidden For the second example, table FOO should have at least as many 
rows
+as the current table to avoid orphaned fields.  address@hidden
+computation time scales as O(N^2) because table FOO is parsed for each field
+to be copied.} for large number of rows.  For the third example, table FOO
+should have at least as many columns as the current table has rows to avoid
+orphaned fields.  By applying this column formula to each column an entire
+table can be transposed.  Inefficient in the same way as the second example.

 @subsubheading Named references
 @cindex named references
--- a/ORGWEBPAGE/Changes.org
+++ b/ORGWEBPAGE/Changes.org
@@ -437,8 +437,10 @@ respectively.  These can be useful in so
 example, to sequentially number the fields in a column, use
 address@hidden as column equation.

-One application is to copy a column from a different table.  See
-the manual for details.
+Other applications are to copy a column from a different table to a
+column, to copy a row from a different table transposed to a column
+or to copy an entire table while transposing it.  See the manual for
+details.

 Thanks to Michael Brand for this feature.

======================================================================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]