Re: [O] problem with empty column

2018-01-06 Thread Eric S Fraga
On Saturday,  6 Jan 2018 at 09:37, Uwe Brauer wrote:
> The column of reference is E1 per default, which is the second one. The

Ah, okay, I understand now.  Thanks.

I see that you have been given a solution elsewhere using vmean but
you could also consider adding "N" to the expression (i.e. after
;E).  This would make the empty entries be treated as having a 0 value
so your check for nan would no longer work but you could always check
for 0...  The following works:

| Name   | E1 | E2 | E3 | E4 | Res |
|+++++-|
| Entry1 |||||  NP |
| Entry2 | 10 | 20 | 30 | 40 |  10 |
| Entry3 | 10 || 20 | 30 |   6 |
#+TBLFM: $6=if("$2" == "(0)" , string("NP"),($2+$3+$4+$5)/10);EN

HTH,
eric

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.6


signature.asc
Description: PGP signature


Re: [O] problem with empty column

2018-01-06 Thread Uwe Brauer
>>> "Michael" == Michael Brand  writes:

Hi Michael
   >  if(typeof(vmean($1..$7)) == 12, string(""), vmean($1..$7); E

This is precisely what I was looking for, thanks a lot. I meanwhile
circumvent the problem by

| Name   | E1 | E2 | E3 | E4 | Pre | Res |
|+++++-+-|
| Entry1 |||||   0 |  NP |
| Entry2 | 10 | 20 | 30 | 40 | 100 |  10 |
| Entry3 | 10 || 20 | 30 |  60 |   6 |
#+TBLFM: $6=$2+$3+$4+$5::$7=if("$2" == "nan", string("NP"),$6/10);E


But your solution is much more elegant.




Re: [O] problem with empty column

2018-01-06 Thread Uwe Brauer
>>> "Eric" == Eric S Fraga  writes:

   > On Friday,  5 Jan 2018 at 13:44, Uwe Brauer wrote:
   >> What I meant is this.

   > I understood what you meant and your code is working properly.  You
   > are checking the second column which is the column labelled E1, not
   > the one labelled E2 which is actually the third column... change your
   > if statement to check $3, not $2.

Maybe the format of the table was distorted.

| Name   | E1 | E2 | E3 | E4 | Res |
|+++++-|
| Entry1 |||||  NP |
| Entry2 | 10 | 20 | 30 | 40 |  10 |
| Entry3 | 10 || 20 | 30 | nan |
#+TBLFM: $6=if("$2" == "nan" , string("NP"),($2+$3+$4+$5)/10);E

The column of reference is E1 per default, which is the second one. The
row labeled Entry1 gives the expected result, NP, since its E1 entry is
empty but in the row labeled Entry3 E1 is not empty, so the second part
of the statement should be applied resulting in 6, but it does not it
results in nan, which I don't understand. The fact that E2 ($3) is empty
should be irrelevant here, but it is not.

On the other hand

| Name   | E1 | E2 | E3 | E4 | Res |
|+++++-|
| Entry1 |||||  NP |
| Entry2 | 10 | 20 | 30 | 40 |  10 |
| Entry3 | 10 |  0 | 20 | 30 |   6 |
#+TBLFM: $6=if("$2" == "nan" , string("NP"),($2+$3+$4+$5)/10);E

Gives the expected result, that is adding 0 to E2 in row Entry3.

I am puzzled

Uwe 




Re: [O] problem with empty column

2018-01-05 Thread Eric S Fraga
On Friday,  5 Jan 2018 at 13:44, Uwe Brauer wrote:
> What I meant is this.

I understood what you meant and your code is working properly.  You
are checking the second column which is the column labelled E1, not
the one labelled E2 which is actually the third column... change your
if statement to check $3, not $2.

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.6


signature.asc
Description: PGP signature


Re: [O] problem with empty column

2018-01-05 Thread Michael Brand
Hi Uwe

On Fri, Jan 5, 2018 at 1:44 PM, Uwe Brauer  wrote:

> But fails if there is a row like this
>
> | Name   | E1 | E2 | E3 | E4 | Res |
> |+++++-|
> | Entry1 |||||  NP |
> | Entry2 | 10 | 20 | 30 | 40 |  10 |
> | Entry3 | 10 || 20 | 30 | nan |
> #+TBLFM: $6=if("$2" == "nan", string("NP"),($2+$3+$4+$5)/10);E

I think you are looking for this:

| Name   | E1 | E2 | E3 | E4 | Res |
|+++++-|
| Entry1 ||||| NP  |
| Entry2 | 10 | 20 | 30 | 40 | 10  |
| Entry3 | 10 || 20 | 30 | NP  |
#+TBLFM: $6 = if(typeof(vsum($2..$5)) == 12 , string("NP"),
vsum($2..$5) / 10); E

See the example

if(typeof(vmean($1..$7)) == 12, string(""), vmean($1..$7); E

in the manual.

Michael



Re: [O] problem with empty column

2018-01-05 Thread Uwe Brauer
"Eric" == Eric S Fraga  writes: 


   > On Friday,  5 Jan 2018 at 09:28, Uwe Brauer wrote: [...] 

   >> The last row behaves strangely the cell in the second 
   >> column is *not* empty but the cell in the third one is, 
   >> nevertheless the cell in the last column contains the 
   >> string nan, which I don't understand. 

   > But the second column is *not* empty; maybe you meant 3rd 
   > column? 


What I meant is this.

Take the following simple table

| Name   | E1 | E2 | E3 | E4 | Res | 
|+++++-| Entry1 | 10 | 30 | 40 | 50 | 
|| Entry2 | 10 | 20 | 30 | 40 | | #+TBLFM: $6=($2+$3+$4+$5)/10 


C-u C-u C-c C-c
leads to 

| Name   | E1 | E2 | E3 | E4 | Res | 
|+++++-| Entry1 | 10 | 30 | 40 | 50 | 
|13 | Entry2 | 10 | 20 | 30 | 40 |  10 | #+TBLFM: 
|$6=($2+$3+$4+$5)/10 

Now for any new entry I want to have in the 6th column NP if the 
entry in the second column (not the whole column) is empty.


| Name   | E1 | E2 | E3 | E4 | Res | 
|+++++-| Entry1 | 10 | 30 | 40 | 50 | 
|13 | Entry2 | 10 | 20 | 30 | 40 |  10 | Entry3 |||| 
|| | 


Should lead to
| Name   | E1 | E2 | E3 | E4 | Res | 
|+++++-| Entry1 | 10 | 30 | 40 | 50 | 
|13 | Entry2 | 10 | 20 | 30 | 40 |  10 | Entry3 |||| 
||  NP | 



How can I achieve that?

The following works well

| Name   | E1 | E2 | E3 | E4 | Res | 
|+++++-| Entry1 ||||| 
|NP  | Entry2 | 10 | 20 | 30 | 40 | 10  | #+TBLFM: $6=if("$2" == 
|"nan" , string("NP"),($2+$3+$4+$5)/10);E 

although the second column is *not* empty, but it is empty for 
Entry 1. 


But fails if there is a row like this


| Name   | E1 | E2 | E3 | E4 | Res | 
|+++++-| Entry1 ||||| 
|NP | Entry2 | 10 | 20 | 30 | 40 |  10 | Entry3 | 10 || 20 | 
|30 | nan | #+TBLFM: $6=if("$2" == "nan" , 
|string("NP"),($2+$3+$4+$5)/10);E 

Uwe 





Re: [O] problem with empty column

2018-01-05 Thread Eric S Fraga
On Friday,  5 Jan 2018 at 09:28, Uwe Brauer wrote:

[...]

> The last row behaves strangely the cell in the second column is *not*
> empty but the cell in the third one is, nevertheless the cell in the
> last column contains the string nan, which I don't understand.

But the second column is *not* empty; maybe you meant 3rd column?

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.6


signature.asc
Description: PGP signature


Re: [O] problem with empty column

2018-01-05 Thread Loris Bennett
Uwe Brauer  writes:

> Hi
>
> Consider please the following table
>
>
>
> | Name   | E1 | E2 | E3 | E4 | Res |
> |+++++-|
> | Entry1 ||||| NP  |
> | Entry2 | 10 | 20 | 30 | 40 | 10  |
>
> #+TBLFM: $6=if("$2" == "nan" , string("NP"),($2+$3+$4+$5)/10);E
>
> The last column contains a string NP if the corresponding cell in the
> second column is empty.
>
> However when   I consider
>
> | Name   | E1 | E2 | E3 | E4 | Res |
> |+++++-|
> | Entry1 |||||  NP |
> | Entry2 | 10 | 20 | 30 | 40 |  10 |
> | Entry3 | 10 || 20 | 30 | nan |
>
> #+TBLFM: $6=if("$2" == "nan" , string("NP"),($2+$3+$4+$5)/10);E
>
> The last row behaves strangely the cell in the second column is *not*
> empty but the cell in the third one is, nevertheless the cell in the
> last column contains the string nan, which I don't understand.
>
> Any help would be appreciated
>
> Thanks
>
> Uwe Brauer 

The empty column for Entry3 is in column 3 and not column 2.  Try
toggling the Col/Row numbers.

Cheers

Loris

-- 
This signature is currently under construction.