emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] How to do a sum of products in a table?


From: Rasmus
Subject: Re: [O] How to do a sum of products in a table?
Date: Fri, 14 Jun 2013 19:34:16 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Alan Schmitt <address@hidden> writes:

> | Name | Grade | Question 1 | Question 2 | Question 3 |
> | Coeff | 6 | 1 | 3 | 2 |
> |-------+-------+------------+------------+------------|
> | Foo | | 1/2 | 1 | 1/4 |
> | Bar | | 1 | 1 | 0 |
> #+TBLFM: @2$2=vsum($3..$>)
>
> I would like the grade of Foo to be 10 * (1/2 * 1 + 1 * 3 + 1/4 * 2)/6
> and Bar to be 10 * (1 * 1 + 1 * 3 + 0 * 2)/6

both are ≈ 6.67.


> Thanks, but I does not seem to do what I want. I prefer to keep the
> coefficient in the column with the question name so that I can easily
> know what it refers to when I adjust it.

So perhaps you'd want something like this

|   | Name      |     Grade | Question 1 | Question 2 | Question 3 |
| ! |           |     grade | q1         |            | q3         |
| _ |           |         g |            |            |            |
| / | Coeff     |         6 | 1          |          3 | 2          |
|---+-----------+-----------+------------+------------+------------|
| * | Foo       |      6.67 | 1/2        |          1 | 1/4        |
| * | Bar       |      6.67 | 1          |          1 | 0          |
| * | Baz       |       7.5 | 1          |        3/2 | -1/2       |
|---+-----------+-----------+------------+------------+------------|
| _ |           |      mean |            |        max |            |
|   | Mean      | 6.9444445 | std.dev.   | 0.48112521 |            |
| $ | Constants |  magic=10 |            |            |            |
|---+-----------+-----------+------------+------------+------------|
#+TBLFM: $g=vsum($q1..$q3):: $3=round(@address@hidden/$g,2)::
#+TBLFM: $mean=vmean(@I$grade..II$grade)::$max=vsdev(@I$grade..II$grade)

It even exports pretty tables so you could hardly wish for more.

–Rasmus

-- 
When in doubt, do it!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]