Hi Thierry

On Tue, Dec 9, 2014 at 11:35 PM, Thierry Banel <tbanelweb...@free.fr> wrote:
> A clean design has been implemented for handling empty cells.

Very good.

> On output, empty cells are generated when the aggregation function does
> not have enough input. For instance, =mean= needs at least one value,
> otherwise a division by zero happens.

The above "not enough input" contradicts with "no input" from the
docstring of orgtbl-aggregate-apply-calc-1arg-function:

    Empty value is returned when all input values are empty.

If this function would follow its docstring by having "(if (cdr vec)"
also for sum, min, max and prod then the user could benefit from
adding "E" and/or "N" or not in the mode string of the TBLFM:

#+TBLNAME: test
| Item | Value_1 | Value_2 |
|------+---------+---------|
| a    |       2 |         |
| a    |       2 |       2 |
| b    |       2 |       2 |
| b    |         |       2 |
| c    |         |       2 |
| c    |         |       2 |
| d    |         |       1 |
| d    |         |      -1 |

#+BEGIN: aggregate :table test :cols ("Item" "sum(Value_1)" "sum(Value_2)")
| Item | sum(Value_1) | sum(Value_2) |   |   |    |
|------+--------------+--------------+---+---+----|
| a    |            4 |            2 | 3 | 3 | >  |
| b    |            2 |            4 | 3 | 3 | <  |
| c    |              |            4 | 4 | 2 | NA |
| d    |              |            0 | 0 | 0 | NA |
#+TBLFM: $4 = vmean($2..$3) :: $5 = vmean($2..$3); EN :: $6 = if("$2"
== "nan" || "$3" == "nan", string("NA"), if($2 > $3, string(">"),
if($2 < $3, string("<"), string("eq")))); E
#+END

The current orgaggregate for comparison:

| Item | sum(Value_1) | sum(Value_2) |   |   |    |
|------+--------------+--------------+---+---+----|
| a    |            4 |            2 | 3 | 3 | >  |
| b    |            2 |            4 | 3 | 3 | <  |
| c    |            0 |            4 | 2 | 2 | <  |
| d    |            0 |            0 | 0 | 0 | eq |

One could still get the current behavior by adding the column formula
~$2 = if("$2" == "nan", 0, $0); E~ etc. for the aggregated columns.

What do you think?

Michael

Reply via email to