[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] Table calculation
From: |
Xiao-Yong Jin |
Subject: |
[Orgmode] Table calculation |
Date: |
Sun, 10 Dec 2006 14:32:42 -0500 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (berkeley-unix) |
Hi, in order to calculate the average with some invalid column, I
managed to write a short elisp script. You can see the difference
between the `0' and the `-' in this table:
| ! | P1 | P2 | P3 | P4 | P5 | Average |
| # | 3.6 | 4.0 | 4.8 | 0 | 4.7 | 3.42 |
| # | 5.0 | 3.3 | - | 4.7 | 4.0 | 4.25 |
#+TBLFM: $7='(let ((data '("$P1" "$P2" "$P3" "$P4" "$P5"))
(n 0)
(total 0))
(while data
(unless (string= (car data) "-")
(setq total
(+ total (string-to-number (car data))))
(setq n (1+ n)))
(setq data (cdr data)))
(/ total n));%.2f
It is reformatted to be more readable, since one cannot put a
multi-line expression in #+TBLFM.
I admit it is really painful to do this. I want to know if anyone
knows how I can simplify this a bit, or if there is a short cut to do
this. I'm not familiar with the internal implementation of org table,
but is there any possibility to make it as a built-in function that I
can put it somewhere in the same org file so that I can easily do some
thing like mymean($P1..$P5)?
Thanks,
Xiao-Yong
--
,,,
(o o)
---ooO-(_)-Ooo---
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Orgmode] Table calculation,
Xiao-Yong Jin <=