From: Rick Frankel <rick@rickster.com>
To: Rainer M Krug <Rainer@krugs.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: Combine tables which are results from calculations?
Date: Wed, 4 Nov 2015 12:50:46 -0500 [thread overview]
Message-ID: <20151104175046.GA19168@eyeBook.home> (raw)
In-Reply-To: <m2oafa3zm3.fsf@krugs.de>
On Wed, Nov 04, 2015 at 10:03:48AM +0100, Rainer M Krug wrote:
> Rick Frankel <rick@rickster.com> 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 :).
next prev parent reply other threads:[~2015-11-04 17:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-03 13:18 Combine tables which are results from calculations? Rainer M Krug
[not found] ` <20151103202732.GA10994@eyeBook.home>
[not found] ` <m2oafa3zm3.fsf@krugs.de>
2015-11-04 17:50 ` Rick Frankel [this message]
2015-11-05 8:20 ` Rainer M Krug
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151104175046.GA19168@eyeBook.home \
--to=rick@rickster.com \
--cc=Rainer@krugs.de \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).