From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rick Frankel Subject: Re: Combine tables which are results from calculations? Date: Wed, 4 Nov 2015 12:50:46 -0500 Message-ID: <20151104175046.GA19168@eyeBook.home> References: <20151103202732.GA10994@eyeBook.home> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43973) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zu2D0-0000hU-Sn for emacs-orgmode@gnu.org; Wed, 04 Nov 2015 12:50:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zu2Cv-0004ny-5H for emacs-orgmode@gnu.org; Wed, 04 Nov 2015 12:50:54 -0500 Received: from mail.rickster.com ([204.62.15.78]:38418) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zu2Cv-0004np-14 for emacs-orgmode@gnu.org; Wed, 04 Nov 2015 12:50:49 -0500 Content-Disposition: inline In-Reply-To: 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: Rainer M Krug Cc: emacs-orgmode@gnu.org On Wed, Nov 04, 2015 at 10:03:48AM +0100, Rainer M Krug wrote: > Rick Frankel writes: > > > On Tue, Nov 03, 2015 at 02:18:05PM +0100, Rainer M Krug wrote: > >> Hi > >> > >> Considering the following example: > > > > here's a way to do it in ruby. There is probably a way in {emacs,cl}-lisp, but > > I'm not sure how... > > > > #+BEGIN_SRC ruby :var a=t1[,0] b=t2[,0] c=t3[,0] :colnames '(a b c) > > r = [a, b, c] > > len = r.collect(&:length).max > > r.each { |l| l.fill('', l.length, len - l.length) } > > a.zip(b, c) > > #+END_SRC > > Thanks - I'll look into this and see if I can do something similar in R > or elisp. Here's a elisp version: * zip lists #+name: a | a | |---| | 1 | | 2 | #+name: b | b | |---| | 4 | | 5 | | 6 | | 7 | | 8 | #+name: c | c | |----| | 9 | | 10 | | 11 | #+BEGIN_SRC emacs-lisp :var a=a[,0] b=b[,0] c=c[,0] :colnames '(a b c) (let* ((l (list a b c)) (max (apply #'max (mapcar #'length l)))) (apply #'mapcar* #'list (mapcar (lambda (x) (append x (make-list (- max (length x)) ""))) l))) #+END_SRC rick Note: previous reply was not to list (whoops) CC'ing the list on this so the answer is saved for posterity :).