Re: [O] Determine min/max values in a table

2017-08-05 Thread Karl Voit
* Adam Porter  wrote:
> Thierry Banel  writes:
>
>> Alternatively you have the orgtbl-aggregate package available on Melpa.
>>
>> #+BEGIN: aggregate :table "myvalues" :cols "min(Values) max(Values)
>> mean(Values)"
>>
>> | min(Values) | max(Values) | mean(Values) |
>> |-+-+--|
>> |   2 |   7 |  4.5 |
>
> Wow, that's very cool!  Had no idea about that package.

Although I do have the package installed, I did not think about
min/max/mean of it ;-)

> Karl, if that doesn't work for you, you might look at the
> org-table-to-lisp function.  Here's an example of a function that uses
> it to sum columns in the current region:

Thanks for the code I copied to my knowledge base.

For now, vmin/vmax did the trick and I also refreshed my knowledge
of orgtbl-aggregate.

-- 
get mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML into Org-mode:
   > get Memacs from https://github.com/novoid/Memacs <
Personal Information Management > http://Karl-Voit.at/tags/pim/
Emacs-related > http://Karl-Voit.at/tags/emacs/




Re: [O] Determine min/max values in a table

2017-08-03 Thread Adam Porter
Thierry Banel  writes:

> Alternatively you have the orgtbl-aggregate package available on Melpa.
>
> #+BEGIN: aggregate :table "myvalues" :cols "min(Values) max(Values)
> mean(Values)"
>
> | min(Values) | max(Values) | mean(Values) |
> |-+-+--|
> |   2 |   7 |  4.5 |

Wow, that's very cool!  Had no idea about that package.

Karl, if that doesn't work for you, you might look at the
org-table-to-lisp function.  Here's an example of a function that uses
it to sum columns in the current region:

#+BEGIN_SRC elisp
(defun org-fitness-sum-table-lines ()
"Sum each numeric column in table lines touched by the region."
(interactive)
(org-with-wide-buffer
 (let* (
;; Add empty column because (org-table-get-specials) leaves the 
empty one out, which throws off the indices
(header (cons nil (org-table-column-names)))
(start (save-excursion
 (goto-line (line-number-at-pos (region-beginning)))
 (line-beginning-position)))
(end (save-excursion
   (goto-line (line-number-at-pos (region-end)))
   (line-end-position)))
(lines (buffer-substring-no-properties start end))
(table (--remove (equal 'hline it)
 (org-table-to-lisp lines)))
(indices (cdr  ; Drop index representing first column, which is 
always empty
  (butlast  ; Drop index representing last column, which is 
comments
   (-find-indices (lambda (col)
(or (string= col "")
(string= col "0")
(string= col "0.0")
(string= col "0.00")
(< 0 (string-to-number col
  (car table)
(sums (cl-loop for i in indices
   collect (-reduce '+ (-map 'string-to-number
 (-select-column i 
table)
(result (-zip (-select-by-indices indices header) sums)))
   (org-fitness-display-values result :prefix "Lines: "
#+END_SRC




Re: [O] Determine min/max values in a table

2017-08-02 Thread Thierry Banel
Le 02/08/2017 14:07, Karl Voit a écrit :
> Hi!
>
> How can I determine minimum and/or maximum value of a table?
>
> Here is my example:
>
> #+NAME: myvalues
> | Values |
> ||
> |  4 |
> |  2 |
> |  3 |
> |  7 |
> |  5 |
> |  6 |
>
> | Min| Max| Average | First | Last |
> |++-+---+--|
> | #ERROR | #ERROR | 4.5 | 4 |6 |
> #+TBLFM: @2$1='(min (remote(myvalues,@2$1..@>$1)))::@2$2='(max 
> (remote(myvalues,@2$1..@>$1)))::@2$3=vmean(remote(myvalues,@2$1..@>$1))::@2$4=remote(myvalues,@2$1)::@2$5=remote(myvalues,@>$1)
>
> My goal is to get min==2 in the first column and max==7 in the
> second.
>

Alternatively you have the orgtbl-aggregate package available on Melpa.

#+BEGIN: aggregate :table "myvalues" :cols "min(Values) max(Values)
mean(Values)"
| min(Values) | max(Values) | mean(Values) |
|-+-+--|
|   2 |   7 |  4.5 |
#+END:




[O] Determine min/max values in a table

2017-08-02 Thread Karl Voit
Hi!

How can I determine minimum and/or maximum value of a table?

Here is my example:

#+NAME: myvalues
| Values |
||
|  4 |
|  2 |
|  3 |
|  7 |
|  5 |
|  6 |

| Min| Max| Average | First | Last |
|++-+---+--|
| #ERROR | #ERROR | 4.5 | 4 |6 |
#+TBLFM: @2$1='(min (remote(myvalues,@2$1..@>$1)))::@2$2='(max 
(remote(myvalues,@2$1..@>$1)))::@2$3=vmean(remote(myvalues,@2$1..@>$1))::@2$4=remote(myvalues,@2$1)::@2$5=remote(myvalues,@>$1)

My goal is to get min==2 in the first column and max==7 in the
second.

-- 
get mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML into Org-mode:
   > get Memacs from https://github.com/novoid/Memacs <
Personal Information Management > http://Karl-Voit.at/tags/pim/
Emacs-related > http://Karl-Voit.at/tags/emacs/