From mboxrd@z Thu Jan 1 00:00:00 1970 From: Uwe Brauer Subject: table lookup combine remote: problems Date: Sat, 16 Jun 2018 16:48:48 +0200 Message-ID: <87d0wq6b3j.fsf@mat.ucm.es> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUCVg-00046P-BZ for emacs-orgmode@gnu.org; Sat, 16 Jun 2018 10:49:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUCVd-0004Hx-9m for emacs-orgmode@gnu.org; Sat, 16 Jun 2018 10:49:00 -0400 Received: from [195.159.176.226] (port=34460 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUCVd-0004Hn-20 for emacs-orgmode@gnu.org; Sat, 16 Jun 2018 10:48:57 -0400 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fUCTT-0007Yk-El for emacs-orgmode@gnu.org; Sat, 16 Jun 2018 16:46:43 +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" To: emacs-orgmode@gnu.org Hello The following works #+TBLNAME: raw-data2 | | Result | |--------+--------| | | 0.5 | | | 1.5 | | | 2.5 | | | 3.5 | | | 4 | | | 7 | | | 7.5 | | | NP | | | NP | |--------+--------| | All:NP | 2 | #+TBLFM: @>$2='(length(org-lookup-all "NP" '(@2$2..@-I$2) nil)) The entries NP in the second column are counted and the result is put in the last row. I also want to the frequency (in a certain range) in the table, but I want the result in a different table, that is why I need the remote function Auxiliary function from the web. #+BEGIN_SRC emacs-lisp (defun in-interval (bounds el) (and (>= el (car bounds)) (<= el (cadr bounds)))) #+END_SRC | lower bound | upper bound | frequency | |-------------+-------------+-----------| | 0.1 | 4.9 | 5 | | 5 | 6.9 | 0 | | 7 | 8.9 | 2 | | 9 | 10 | 0 | #+TBLFM: $3='(length (org-lookup-all '($1 $2) '(remote(raw-data2,@2$1..@>$1)) nil 'in-interval));N Works. Now I want to combine the first org-lookup with the second one and have the result in a different table so I tried | lower bound | upper bound | frequency | |-------------+-------------+-----------| | 0.1 | 4.9 | 0 | | 5 | 6.9 | 0 | | 7 | 8.9 | 0 | | 9 | 10 | 0 | |-------------+-------------+-----------| | | | 1 | #+TBLFM: $3='(length (org-lookup-all '($1 $2) '(remote(raw-data2,@2$1..@>$1)) nil 'in-interval));N::@>$2='(length(org-lookup-all "NP" '(remote(raw-data2,@2$2..@-I$2)) nil)) But this does not work. Any help would be strongly appreciated. Thanks Uwe Brauer