From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Gabriel Peters" Subject: Re: Re: evaluating rows or columns in org-table Date: Wed, 30 Jul 2008 10:49:48 -0700 Message-ID: References: <489075C5.807@gmail.com> <87od4fqtxp.fsf@gollum.intra.norang.ca> <87d4kvqrki.fsf@gollum.intra.norang.ca> <8763qnqre1.fsf@gollum.intra.norang.ca> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0076339227==" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KOFo6-0001WD-RR for emacs-orgmode@gnu.org; Wed, 30 Jul 2008 13:49:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KOFo6-0001V8-1w for emacs-orgmode@gnu.org; Wed, 30 Jul 2008 13:49:50 -0400 Received: from [199.232.76.173] (port=53048 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KOFo5-0001Uf-M1 for emacs-orgmode@gnu.org; Wed, 30 Jul 2008 13:49:49 -0400 Received: from qb-out-1314.google.com ([72.14.204.168]:28237) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KOFo5-0007Gt-8i for emacs-orgmode@gnu.org; Wed, 30 Jul 2008 13:49:49 -0400 Received: by qb-out-1314.google.com with SMTP id d2so131982qbc.30 for ; Wed, 30 Jul 2008 10:49:48 -0700 (PDT) In-Reply-To: <8763qnqre1.fsf@gollum.intra.norang.ca> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bernt Hansen Cc: Kene Meniru , emacs-orgmode@gnu.org --===============0076339227== Content-Type: multipart/alternative; boundary="----=_Part_10880_6566016.1217440188108" ------=_Part_10880_6566016.1217440188108 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Wed, Jul 30, 2008 at 9:16 AM, Bernt Hansen wrote: > Sorry that last post was unfinished. > > Here's my attempt at fixing the student rank > > | | Rank | names | grade 1 | grade 2 | grade 3 | Total | Letter > grade | > > |---+------+------------+---------+---------+---------+-------+--------------| > | # | 1 | student 01 | 91.80 | 96.40 | 97.00 | 95.07 | A > | > | # | 3 | student 03 | 92.00 | 95.14 | 97.00 | 94.71 | A > | > | # | 2 | student 02 | 88.78 | 89.15 | 98.00 | 91.98 | A > | > | # | 4 | student 04 | 84.00 | 74.62 | 88.00 | 82.21 | B > | > #+TBLFM: > $7=($4+$5+$6)/3;%.2f::$8=if($7<60,F,if($7<70,D,if($7<80,C,if($7<90,B,A))))::@2$2=1::$2=@-1+1 > > You can sort the table by the total column descending to get the rank. > > If you sort the resulting table like this: > > 1) Position cursor on any total value > 2) M-x org-table-sort-lines > 3) N (for reverse numeric sort) > > Then update the Rank column with C-u C-u C-c C-c anywhere in the table > the rank numbers are recomputed starting from 1 on the first row. > > I hope your blank lines aren't too important because sorting puts them > all at the bottom of the table. The blank lines do also pose a problem in different approach, one which will make use of vector functions in calc. If you allow for no empty lines and one extra line toward the end of table, this also can do the computation. | | Rank | names | grade 1 | grade 2 | grade 3 | Total | Letter grade | |---+------+------------+---------+---------+---------+-------+--------------| | # | 1 | student 01 | 91.80 | 96.40 | 97.00 | 95.07 | A | | # | 2 | student 03 | 92.00 | 95.14 | 97.00 | 94.71 | A | | # | 3 | student 02 | 88.78 | 89.15 | 98.00 | 91.98 | A | | # | 4 | student 04 | 84.00 | 74.62 | 88.00 | 82.21 | B | |---+------+------------+---------+---------+---------+-------+--------------| #+TBLFM: $2=find(rsort(@I$7..@II $7),$7)::$7=($4+$5+$6)/3;%.2f::$8=if($7<60,F,if($7<70,D,if($7<80,C,if($7<90,B,A)))) > > Does that do what you want? > > -Bernt > > > _______________________________________________ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode > ------=_Part_10880_6566016.1217440188108 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline


On Wed, Jul 30, 2008 at 9:16 AM, Bernt Hansen <bernt@norang.ca> wrote:
Sorry that last post was unfinished.

Here's my attempt at fixing the student rank

|   | Rank | names      | grade 1 | grade 2 | grade 3 | Total | Letter grade |
|---+------+------------+---------+---------+---------+-------+--------------|
| # |    1 | student 01 |   91.80 |   96.40 |   97.00 | 95.07 | A            |
| # |    3 | student 03 |   92.00 |   95.14 |   97.00 | 94.71 | A            |
| # |    2 | student 02 |   88.78 |   89.15 |   98.00 | 91.98 | A            |
| # |    4 | student 04 |   84.00 |   74.62 |   88.00 | 82.21 | B            |
#+TBLFM: $7=($4+$5+$6)/3;%.2f::$8=if($7<60,F,if($7<70,D,if($7<80,C,if($7<90,B,A))))::@2$2=1::$2=@-1+1

You can sort the table by the total column descending to get the rank.

If you sort the resulting table like this:

 1) Position cursor on any total value
 2) M-x org-table-sort-lines
 3) N (for reverse numeric sort)

Then update the Rank column with C-u C-u C-c C-c anywhere in the table
the rank numbers are recomputed starting from 1 on the first row.

I hope your blank lines aren't too important because sorting puts them
all at the bottom of the table.


The blank lines do also pose a problem in different approach, one which will make use of vector functions in calc. If you allow for no empty lines and one extra line toward the end of table, this also can do the computation.
 

|   | Rank | names      | grade 1 | grade 2 | grade 3 | Total | Letter grade |
|---+------+------------+---------+---------+---------+-------+--------------|
| # |    1 | student 01 |   91.80 |   96.40 |   97.00 | 95.07 | A            |
| # |    2 | student 03 |   92.00 |   95.14 |   97.00 | 94.71 | A            |
| # |    3 | student 02 |   88.78 |   89.15 |   98.00 | 91.98 | A            |
| # |    4 | student 04 |   84.00 |   74.62 |   88.00 | 82.21 | B            |
|---+------+------------+---------+---------+---------+-------+--------------|
#+TBLFM: $2=find(rsort(@I$7..@II$7),$7)::$7=($4+$5+$6)/3;%.2f::$8=if($7<60,F,if($7<70,D,if($7<80,C,if($7<90,B,A))))




Does that do what you want?

-Bernt


_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

------=_Part_10880_6566016.1217440188108-- --===============0076339227== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --===============0076339227==--