all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Can't import a remote reference to a whole column in orgtbl
@ 2010-02-26  0:43 Ismael Barros²
  2010-02-26  0:54 ` Ismael Barros²
  0 siblings, 1 reply; 14+ messages in thread
From: Ismael Barros² @ 2010-02-26  0:43 UTC (permalink / raw)
  To: emacs-orgmode

Hi, I'm new to org-mode and orgtbl, please don't hit me too hard with
a stick if what I'm asking is retarded :)

I'm using org-mode with orgtbl inside a Latex document. I'm making
extensive use of remote references to other tables inside the
document. If I reference a cell, for example, with
"remote(results_par,@2$9)", it works as expected, but if I reference a
whole column, with "remote(results_par,$9)", it doesn't work: instead
of column 9 from "results_par" table, I get column 9 from the table
I'm woking on.

Am I doing something wrong or did I stumble with a bug in orgtbl? Any
workaround or version that has it fixed? I would *really* appreciate
some help, deadlines are crushing me!

Regards, and thanks in advance!
Ismael

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Can't import a remote reference to a whole column in orgtbl
  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
  0 siblings, 1 reply; 14+ messages in thread
From: Ismael Barros² @ 2010-02-26  0:54 UTC (permalink / raw)
  To: emacs-orgmode

This would probably help:

Source table:

#+TBLNAME: results_par
#+ORGTBL: SEND results_par orgtbl-to-latex :splice t :skip 2
  |   | proc |    t1 |       |    t2 |       |      |   t3 |       |      |
  |---+------+-------+-------+-------+-------+------+------+-------+------|
  | # |    1 |  1.72 |  1.72 | 60.21 |  0.89 | 0.89 | 8.84 |  0.87 | 0.87 |
  | # |    2 | 32.66 | 16.33 | 30.37 |  1.77 | 0.89 | 4.41 |  1.74 | 0.87 |
  | # |    4 | 37.26 |  9.31 | 15.63 |  3.44 | 0.86 | 2.22 |  3.45 | 0.86 |
  | # |    8 | 36.36 |  4.54 |  8.12 |  6.62 | 0.83 | 1.11 |  6.90 | 0.86 |
  | # |   16 | 38.90 |  2.43 |  4.38 | 12.28 | 0.77 | 0.56 | 13.68 | 0.85 |
#+TBLFM: $3=$0;%.2f :: $4=@$-1/@$2;%.2f ::
                            $5=$0;%.2f ::
$6=remote(results_seq,@2$1)/@$-1;%.2f :: $7=@$-1/@$2;%.2f ::        \
        $8=$0;%.2f :: $9=remote(results_seq,@2$2)/@$-1;%.2f :: $10=@$-1/@$2;%.2f
  % $


Destination table:

#+ORGTBL: SEND results1_2 orgtbl-to-latex :splice t :skip 2
  |   | proc |    t1 |      |      |    t2 |      |      |   t3 |      |      |
  |---+------+-------+------+------+-------+------+------+------+------+------|
  | # |    1 |  1.59 | 1.00 | 1.00 | 40.05 | 0.02 | 0.02 | 8.34 | 8.34 | 8.34 |
  | # |    2 | 37.28 | 1.00 | 0.50 | 20.29 | 0.02 | 0.01 | 4.17 | 4.17 | 2.08 |
  | # |    4 | 34.91 | 1.00 | 0.25 | 10.43 | 0.02 | 0.01 | 2.13 | 2.13 | 0.53 |
  | # |    8 | 36.36 | 1.00 | 0.12 |  5.42 | 0.02 | 0.00 | 1.05 | 1.05 | 0.13 |
  | # |   16 | 38.93 | 1.00 | 0.06 |  3.03 | 0.02 | 0.00 | 0.53 | 0.53 | 0.03 |
#+TBLFM: $3=$0;%.2f :: $4=remote(results_par,$3)/@$-1;%.2f ::
$5=@$-1/@$2;%.2f ::                 $6=$0;%.2f ::
$7=remote(results_par,$5)/@$-1;%.2f :: $8=@$-1/@$2;%.2f ::           \
      $9=$0;%.2f :: $10=remote(results_par,$9);%.2f :: $11=@$-1/@$2;%.2f
  % $

Note how $10=remote(results_par,$9) yields $10=$9.

Also, this happened on org-mode 6.34c-5 and org-mode from git.

Regards,
Ismael

On Fri, Feb 26, 2010 at 1:43 AM, Ismael Barros² <razielmine@gmail.com> wrote:
> Hi, I'm new to org-mode and orgtbl, please don't hit me too hard with
> a stick if what I'm asking is retarded :)
>
> I'm using org-mode with orgtbl inside a Latex document. I'm making
> extensive use of remote references to other tables inside the
> document. If I reference a cell, for example, with
> "remote(results_par,@2$9)", it works as expected, but if I reference a
> whole column, with "remote(results_par,$9)", it doesn't work: instead
> of column 9 from "results_par" table, I get column 9 from the table
> I'm woking on.
>
> Am I doing something wrong or did I stumble with a bug in orgtbl? Any
> workaround or version that has it fixed? I would *really* appreciate
> some help, deadlines are crushing me!
>
> Regards, and thanks in advance!
> Ismael
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Re: Can't import a remote reference to a whole column in orgtbl
  2010-02-26  0:54 ` Ismael Barros²
@ 2010-02-26  9:27   ` Giovanni Ridolfi
  2010-04-03 17:24     ` Ismael Barros²
  0 siblings, 1 reply; 14+ messages in thread
From: Giovanni Ridolfi @ 2010-02-26  9:27 UTC (permalink / raw)
  To: Ismael Barros²; +Cc: emacs-orgmode

> Ismael Barros² <razielmine@gmail.com> writes:

Hi, Ismael

>> Hi, I'm new to org-mode and orgtbl, please don't hit me too hard with
>> a stick if what I'm asking is retarded :)
well a google search would have shown
http://comments.gmane.org/gmane.emacs.orgmode/21439
;-)

>>
>> I'm using org-mode with orgtbl inside a Latex document. I'm making
>> extensive use of remote references to other tables inside the
>> document. 
>> If I reference a cell, for example, with
>> "remote(results_par,@2$9)", it works as expected, 
>> but if I reference a whole column, 

You cannot. This is the answer by Carsten:

"ranges are possible in remote references.  However, what
is not allowed it to assign them to a range.  On the left
side of equations you can only have single fields
like @2$3 or a column like $3.

So you might ask what the use of range references then
is?  You can put the ranges into calc functions like
vsum or vmean, or you can get them as lists in an
elisp formula."


cheers,
Giovanni

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Re: Can't import a remote reference to a whole column in orgtbl
  2010-02-26  9:27   ` Giovanni Ridolfi
@ 2010-04-03 17:24     ` Ismael Barros²
  2010-04-04  6:47       ` Carsten Dominik
  0 siblings, 1 reply; 14+ messages in thread
From: Ismael Barros² @ 2010-04-03 17:24 UTC (permalink / raw)
  To: Giovanni Ridolfi; +Cc: emacs-orgmode

My bad, I should have googled harder :)

Just out of curiosity: is this limitation there by design, or is it
waiting for some workforce to complete it? I finally just copy+pasted
the columns I needed, but being able to import whole rows/columns
would be incredibly useful.

Regards,
Ismael

On Fri, Feb 26, 2010 at 10:27 AM, Giovanni Ridolfi
<giovanni.ridolfi@yahoo.it> wrote:
>> Ismael Barros² <razielmine@gmail.com> writes:
>
> Hi, Ismael
>
>>> Hi, I'm new to org-mode and orgtbl, please don't hit me too hard with
>>> a stick if what I'm asking is retarded :)
> well a google search would have shown
> http://comments.gmane.org/gmane.emacs.orgmode/21439
> ;-)
>
>>>
>>> I'm using org-mode with orgtbl inside a Latex document. I'm making
>>> extensive use of remote references to other tables inside the
>>> document.
>>> If I reference a cell, for example, with
>>> "remote(results_par,@2$9)", it works as expected,
>>> but if I reference a whole column,
>
> You cannot. This is the answer by Carsten:
>
> "ranges are possible in remote references.  However, what
> is not allowed it to assign them to a range.  On the left
> side of equations you can only have single fields
> like @2$3 or a column like $3.
>
> So you might ask what the use of range references then
> is?  You can put the ranges into calc functions like
> vsum or vmean, or you can get them as lists in an
> elisp formula."
>
>
> cheers,
> Giovanni
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Re: Can't import a remote reference to a whole column in orgtbl
  2010-04-03 17:24     ` Ismael Barros²
@ 2010-04-04  6:47       ` Carsten Dominik
  2010-04-04 19:02         ` Michael Brand
  0 siblings, 1 reply; 14+ messages in thread
From: Carsten Dominik @ 2010-04-04  6:47 UTC (permalink / raw)
  To: Ismael Barros², Michael Brand; +Cc: Org-Mode List


On Apr 3, 2010, at 7:24 PM, Ismael Barros² wrote:

> My bad, I should have googled harder :)
>
> Just out of curiosity: is this limitation there by design, or is it
> waiting for some workforce to complete it? I finally just copy+pasted
> the columns I needed, but being able to import whole rows/columns
> would be incredibly useful.

There is actually now a way to do tis - even though it is  
inefficient.  To copy column 2 from table FOO into column 3 of the  
current table, use

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

This is now possible due to a patch by Michael Brand:

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

It works well, but it is inefficient because this formula will
parse the FOO table again for each field to be copied.

HTH

- Carsten


>
> Regards,
> Ismael
>
> On Fri, Feb 26, 2010 at 10:27 AM, Giovanni Ridolfi
> <giovanni.ridolfi@yahoo.it> wrote:
>>> Ismael Barros² <razielmine@gmail.com> writes:
>>
>> Hi, Ismael
>>
>>>> Hi, I'm new to org-mode and orgtbl, please don't hit me too hard  
>>>> with
>>>> a stick if what I'm asking is retarded :)
>> well a google search would have shown
>> http://comments.gmane.org/gmane.emacs.orgmode/21439
>> ;-)
>>
>>>>
>>>> I'm using org-mode with orgtbl inside a Latex document. I'm making
>>>> extensive use of remote references to other tables inside the
>>>> document.
>>>> If I reference a cell, for example, with
>>>> "remote(results_par,@2$9)", it works as expected,
>>>> but if I reference a whole column,
>>
>> You cannot. This is the answer by Carsten:
>>
>> "ranges are possible in remote references.  However, what
>> is not allowed it to assign them to a range.  On the left
>> side of equations you can only have single fields
>> like @2$3 or a column like $3.
>>
>> So you might ask what the use of range references then
>> is?  You can put the ranges into calc functions like
>> vsum or vmean, or you can get them as lists in an
>> elisp formula."
>>
>>
>> cheers,
>> Giovanni
>>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Re: Can't import a remote reference to a whole column in orgtbl
  2010-04-04  6:47       ` Carsten Dominik
@ 2010-04-04 19:02         ` Michael Brand
  2010-04-04 20:08           ` Carsten Dominik
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Brand @ 2010-04-04 19:02 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Org-Mode List

Carsten Dominik wrote:
>> but being able to import whole rows/columns
>> would be incredibly useful.
> 
> There is actually now a way to do tis - even though it is inefficient.  
> To copy column 2 from table FOO into column 3 of the current table, use
> 
>  #+TBLFM: $3=remote(FOO,@@#$2)
> 
> This is now possible due to a patch by Michael Brand:
>     http://thread.gmane.org/gmane.emacs.orgmode/22930
> 
> It works well, but it is inefficient because this formula will
> parse the FOO table again for each field to be copied.

Very nice use case for `@#'. How about a doc update somehow like this?

=============================================================================
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -2061,10 +2061,15 @@ see the @samp{E} mode switch below).  If
  For Calc formulas and Lisp formulas @code{@@#} and @code{$#} can be used to
  get the row or column number of the field where the formula result goes.
  The traditional Lisp formula equivalents are @code{org-table-current-dline}
-and @code{org-table-current-column}.  Example:
+and @code{org-table-current-column}.  Examples:

  @example
-if(@@# % 2, $#, string(""))      @r{column number on odd lines only}
+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@footnote{Both
+tables must have the same count of rows.  Inefficient for a large count N of
+rows with a time complexity of O(N^2) because all rows of the FOO table will
+be parsed again for each field to be copied.}}
  @end example

  @subsubheading Named references
=============================================================================

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Re: Can't import a remote reference to a whole column in orgtbl
  2010-04-04 19:02         ` Michael Brand
@ 2010-04-04 20:08           ` Carsten Dominik
  2010-04-05  6:11             ` Michael Brand
  0 siblings, 1 reply; 14+ messages in thread
From: Carsten Dominik @ 2010-04-04 20:08 UTC (permalink / raw)
  To: Michael Brand; +Cc: Org-Mode List

Applied, thanks.

- Carsten

On Apr 4, 2010, at 9:02 PM, Michael Brand wrote:

> Carsten Dominik wrote:
>>> but being able to import whole rows/columns
>>> would be incredibly useful.
>> There is actually now a way to do tis - even though it is  
>> inefficient.  To copy column 2 from table FOO into column 3 of the  
>> current table, use
>> #+TBLFM: $3=remote(FOO,@@#$2)
>> This is now possible due to a patch by Michael Brand:
>>    http://thread.gmane.org/gmane.emacs.orgmode/22930
>> It works well, but it is inefficient because this formula will
>> parse the FOO table again for each field to be copied.
>
> Very nice use case for `@#'. How about a doc update somehow like this?
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- a/doc/org.texi
> +++ b/doc/org.texi
> @@ -2061,10 +2061,15 @@ see the @samp{E} mode switch below).  If
> For Calc formulas and Lisp formulas @code{@@#} and @code{$#} can be  
> used to
> get the row or column number of the field where the formula result  
> goes.
> The traditional Lisp formula equivalents are @code{org-table-current- 
> dline}
> -and @code{org-table-current-column}.  Example:
> +and @code{org-table-current-column}.  Examples:
>
> @example
> -if(@@# % 2, $#, string(""))      @r{column number on odd lines only}
> +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@footnote{Both
> +tables must have the same count of rows.  Inefficient for a large  
> count N of
> +rows with a time complexity of O(N^2) because all rows of the FOO  
> table will
> +be parsed again for each field to be copied.}}
> @end example
>
> @subsubheading Named references
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================

- Carsten

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Re: Can't import a remote reference to a whole column in orgtbl
  2010-04-04 20:08           ` Carsten Dominik
@ 2010-04-05  6:11             ` Michael Brand
  2010-04-05  6:48               ` Carsten Dominik
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Brand @ 2010-04-05  6:11 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Org-Mode List

Carsten Dominik wrote:
> Applied, thanks.

Thank you. Looking forward to 6.35 I am watching Changes.org and have seen a 
typo which I think is worth to be pointed out:

======================================================================
--- a/ORGWEBPAGE/Changes.org
+++ b/ORGWEBPAGE/Changes.org
@@ -437,7 +437,7 @@ respectively.  These can be useful in so
  example, to sequentially number the fields in a column, use
  ~=@#~ as column equation.

-One application is to copy a copy from a different table.  See
+One application is to copy a column from a different table.  See
  the manual for details.

  Thanks to Michael Brand for this feature.
======================================================================

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Re: Can't import a remote reference to a whole column in orgtbl
  2010-04-05  6:11             ` Michael Brand
@ 2010-04-05  6:48               ` Carsten Dominik
  2010-04-05 18:26                 ` Michael Brand
  0 siblings, 1 reply; 14+ messages in thread
From: Carsten Dominik @ 2010-04-05  6:48 UTC (permalink / raw)
  To: Michael Brand; +Cc: Org-Mode List


On Apr 5, 2010, at 8:11 AM, Michael Brand wrote:

> Carsten Dominik wrote:
>> Applied, thanks.
>
> Thank you. Looking forward to 6.35 I am watching Changes.org and  
> have seen a typo which I think is worth to be pointed out:

Thanks, applied.  Pheuw, I will be very glad when I get this release  
out - but I am waiting a few more days to see if the LaTeX issues are  
solved....

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 :-)

- Carsten

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Re: Can't import a remote reference to a whole column in orgtbl
  2010-04-05  6:48               ` Carsten Dominik
@ 2010-04-05 18:26                 ` Michael Brand
  2010-04-06  5:15                   ` Carsten Dominik
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Brand @ 2010-04-05 18:26 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Org-Mode List

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, `@#' 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 
`@$#' from the column number `$#' and the column number `$@#' from the row 
number `@#' 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, @$#$@#) :: $2 = remote(FOO, @$#$@#) :: $3 = 
remote(FOO, @$#$@#) :: $4 = remote(FOO, @$#$@#)

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

-@noindent For the second example, table FOO must have at least as many rows
-as the current table.  Inefficient@footnote{The computation time scales as
-O(N^2) because table FOO is parsed for each field to be copied.} for large
-number of rows.
+@noindent For the second example, table FOO should have at least as many rows
+as the current table to avoid orphaned fields.  Inefficient@footnote{The
+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
  ~=@#~ 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.

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Re: Can't import a remote reference to a whole column in orgtbl
  2010-04-05 18:26                 ` Michael Brand
@ 2010-04-06  5:15                   ` Carsten Dominik
  2010-04-07 19:55                     ` Michael Brand
  0 siblings, 1 reply; 14+ messages in thread
From: Carsten Dominik @ 2010-04-06  5:15 UTC (permalink / raw)
  To: Michael Brand; +Cc: Org-Mode List

Hi Michael,

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?

Thanks.

Also:

On Apr 5, 2010, at 8:26 PM, Michael Brand wrote:
>
> -@noindent For the second example, table FOO must have at least as  
> many rows
> -as the current table.  Inefficient@footnote{The computation time  
> scales as
> -O(N^2) because table FOO is parsed for each field to be copied.}  
> for large
> -number of rows.


"At least" because you can also put a partial column into a shorter  
column
in the new table.

- Carsten

> +@noindent For the second example, table FOO should have at least as  
> many rows
> +as the current table to avoid orphaned fields.   
> Inefficient@footnote{The
> +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
> ~=@#~ 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.
>
> ======================================================================

- Carsten

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Re: Can't import a remote reference to a whole column in orgtbl
  2010-04-06  5:15                   ` Carsten Dominik
@ 2010-04-07 19:55                     ` Michael Brand
  2011-11-01 21:14                       ` [Orgmode] " Nick Dokos
  2011-11-01 21:23                       ` Nick Dokos
  0 siblings, 2 replies; 14+ messages in thread
From: Michael Brand @ 2010-04-07 19:55 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Org-Mode List

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Orgmode] Re: Can't import a remote reference to a whole column in orgtbl
  2010-04-07 19:55                     ` Michael Brand
@ 2011-11-01 21:14                       ` Nick Dokos
  2011-11-01 21:23                       ` Nick Dokos
  1 sibling, 0 replies; 14+ messages in thread
From: Nick Dokos @ 2011-11-01 21:14 UTC (permalink / raw)
  To: Michael Brand; +Cc: nicholas.dokos, Org-Mode List, Carsten Dominik

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.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Orgmode] Re: Can't import a remote reference to a whole column in orgtbl
  2010-04-07 19:55                     ` Michael Brand
  2011-11-01 21:14                       ` [Orgmode] " Nick Dokos
@ 2011-11-01 21:23                       ` Nick Dokos
  1 sibling, 0 replies; 14+ messages in thread
From: Nick Dokos @ 2011-11-01 21:23 UTC (permalink / raw)
  To: Michael Brand; +Cc: nicholas.dokos, Org-Mode List, Carsten Dominik

[Aaaargh: premature communication - apologies to all and let me try again]

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: 

| 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, @$#$@#) :: $2 = remote(FOO, @$#$@#) :: $3 = remote(FOO, @$#$@#) :: $4 = remote(FOO, @$#$@#)

And voilà - 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 have 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..@>$> = remote(FOO, @$#$@#)

Nick

Footnotes:

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-11-01 21:23 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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                       ` [Orgmode] " Nick Dokos
2011-11-01 21:23                       ` Nick Dokos

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.