From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Banel Subject: Re: very long table calc expressions ? Date: Wed, 20 Jun 2018 08:13:06 +0200 Message-ID: <5B29F072.4040805@free.fr> References: <87k1qu1yl5.fsf@mat.ucm.es> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVWMi-0001w6-8Z for emacs-orgmode@gnu.org; Wed, 20 Jun 2018 02:13:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVWMf-0003dc-3M for emacs-orgmode@gnu.org; Wed, 20 Jun 2018 02:13:12 -0400 Received: from smtp3-g21.free.fr ([212.27.42.3]:42097) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fVWMe-0003dC-Si for emacs-orgmode@gnu.org; Wed, 20 Jun 2018 02:13:09 -0400 Received: from [IPv6:2a01:e35:2e21:def0:d057:bfbe:531d:78b3] (unknown [IPv6:2a01:e35:2e21:def0:d057:bfbe:531d:78b3]) by smtp3-g21.free.fr (Postfix) with ESMTP id 0944A13F8E3 for ; Wed, 20 Jun 2018 08:13:06 +0200 (CEST) In-Reply-To: <87k1qu1yl5.fsf@mat.ucm.es> 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" To: emacs-orgmode@gnu.org Le 19/06/2018 19:21, Uwe Brauer a =E9crit : > > Hi > > Take the following example > > > #+TBLNAME: data > | Name | Cual 1 | > |------+--------| > | A | NT | > | B | NT | > | C | MH | > | D | AP | > | E | MH | > | F | SS | > | G | NP | > | H | NP | > | I | NP | > | | NT | > | | AP | > | | AP | > | | AP | > | | AP | > | | SB | > > > #+TBLNAME: stat-final2 > | | Frequency | > |----+-----------| > | SS | 1 | > | AP | 5 | > | NT | 3 | > | SB | 1 | > | MH | 2 | > | NP | 3 | > #+TBLFM: @>$2=3D'(length (org-lookup-all "NP" '(remote(data,@2$2..@>I$2= )) nil))::@>>$2=3D'(length (org-lookup-all "MH" '(remote(data,@2$2..@>I$2= )) nil))::@>>>$2=3D'(length (org-lookup-all "SB" '(remote(data,@2$2..@>I$= 2)) nil))::@>>>>$2=3D'(length (org-lookup-all "NT" '(remote(data,@2$2..@>= I$2)) nil))::@>>>>>$2=3D'(length (org-lookup-all "AP" '(remote(data,@2$2.= .@>I$2)) nil))::@>>>>>>$2=3D'(length (org-lookup-all "SS" '(remote(data,@= 2$2..@>I$2)) nil)) > > > Are there any rules to break this very long expression? > > Thanks > > Uwe Brauer > > > You may want to take a look at the orgtbl-aggregate package available on=20 Melpa. #+BEGIN: aggregate :table "data" :cols "'Cual 1' count()" | 'Cual 1' | count() | |----------+---------| | NT | 3 | | MH | 2 | | AP | 5 | | SS | 1 | | NP | 3 | | SB | 1 | #+END: It features the count() function which computes frequency, but also sum,=20 mean, filtering and much more. Documentation here: https://github.com/tbanel/orgaggregate To gain access to the Melpa repository I have those settings in my=20 .emacs file: (require 'package) (setq package-enable-at-startup nil) ; To prevent initialising twice (add-to-list 'package-archives '("gnu" .=20 "http://elpa.gnu.org/packages/" ) t) (add-to-list 'package-archives '("melpa" .=20 "http://melpa.milkbox.net/packages/") t) (package-initialize) Have fun Thierry