From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: How to do a sum of products in a table? Date: Fri, 14 Jun 2013 19:34:16 +0200 Message-ID: <87y5ac61gn.fsf@pank.home> References: <87mwqs7mjv.fsf@pank.home> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnXtX-0005Vm-6P for emacs-orgmode@gnu.org; Fri, 14 Jun 2013 13:34:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UnXtV-00045Z-Vb for emacs-orgmode@gnu.org; Fri, 14 Jun 2013 13:34:39 -0400 Received: from plane.gmane.org ([80.91.229.3]:39395) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnXtV-00045P-Ny for emacs-orgmode@gnu.org; Fri, 14 Jun 2013 13:34:37 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UnXtR-0003aw-LX for emacs-orgmode@gnu.org; Fri, 14 Jun 2013 19:34:33 +0200 Received: from business-213-023-238-209.static.arcor-ip.net ([213.23.238.209]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 14 Jun 2013 19:34:33 +0200 Received: from rasmus by business-213-023-238-209.static.arcor-ip.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 14 Jun 2013 19:34:33 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Alan Schmitt 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(@I-1$q1..@I-1$q3*$q1..$q3*$magic/$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!