From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gunnar Wolf Subject: Tables for attendance lists - A problem understanding TBLFM? Date: Mon, 8 Apr 2013 18:57:53 -0500 Message-ID: <20130408235753.GC109669@gwolf.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:56515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPLwk-00020K-QE for emacs-orgmode@gnu.org; Mon, 08 Apr 2013 19:58:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPLwi-0003da-A2 for emacs-orgmode@gnu.org; Mon, 08 Apr 2013 19:57:58 -0400 Received: from lafa.iiec.unam.mx ([132.248.72.141]:49797) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPLwi-0003dK-3Y for emacs-orgmode@gnu.org; Mon, 08 Apr 2013 19:57:56 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by lafa.iiec.unam.mx (Postfix) with ESMTP id 5054E9381A for ; Mon, 8 Apr 2013 18:57:54 -0500 (CDT) Received: from lafa.iiec.unam.mx ([127.0.0.1]) by localhost (lafa.iiec.unam.mx [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zKDRJ++Z3X1Q for ; Mon, 8 Apr 2013 18:57:53 -0500 (CDT) Received: from v.gwolf.org (unknown [132.248.72.123]) by lafa.iiec.unam.mx (Postfix) with ESMTP id DFBE492702 for ; Mon, 8 Apr 2013 18:57:53 -0500 (CDT) Content-Disposition: inline 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 Hi, As mostly everything for my class work is handled through org-mode, I am trying to use it also for tracking attendance. And it almost works (given my quite-probably-wrong way to solve it) =E2=80=94 Can you help me pinpoint what am I doing wrong? In case it's not obvious, I'm a complete Lisp newbie. My attendance tables look similar to: #+CAPTION: Attendances for April |---------+-------------------+---+---+---+---+----+-------| | Account | Name | 1 | 3 | 5 | 8 | 10 | Total | |---------+-------------------+---+---+---+---+----+-------| | 1234 | C=C3=A1rdenas, L=C3=A1zaro | X | | X | X | | 3 | | 5678 | Madero, Francisco | X | X | X | X | | 4 | | 1544 | Villa, Pancho | | | | | | 1 | | 0113 | Zapata, Emiliano | | X | X | | | 2 | |---------+-------------------+---+---+---+---+----+-------| | Day avg | 2.25 | 2 | 2 | 3 | 2 | 1 | 2.50 | |---------+-------------------+---+---+---+---+----+-------| #+tblfm: @2$8..@5$8=3D'(length '($3..$7))::@6$2=3Dvmean($3..$7);%.2f::@6$= 3..@6$7=3D'(length '(@2..@5))::@6$8=3Dvmean(@2..@5);%.2f The formula tries to fill all of the numeric values (last row and column), but has two important bugs. First, the (attempted) logic: - Last column includes the sum of nonempty cells. I did this by counting the vector's length =E2=80=94 But, as you can see, Pancho Vill= a lives up to his rebel's name and has consistently failed to come to class. Still, his entry shows he attended once. Digging a bit, I found (via M-:) that while (vconcat "X" nil "X" "X") yields a three element vector [88 88 88], and (vconcat nil nil nil) correctly yields an empty vector []. Getting the length of [] correctly gives 0. So, I must be doing something wrong. Can you spot it? - This same problem happens of course, getting the daily averages =E2=80=94 We haven't yet reached April 10, but it shows one attendance. So, is there a way to unb0rk my lists? Org-mode seems to be quite well equiped for this task, and I'd hate to use other tools if I can stick to this :)