[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Combine tables which are results from calculations?
From: |
Rainer M Krug |
Subject: |
Re: [O] Combine tables which are results from calculations? |
Date: |
Thu, 05 Nov 2015 09:20:36 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) |
Rick Frankel <address@hidden> writes:
> On Wed, Nov 04, 2015 at 10:03:48AM +0100, Rainer M Krug wrote:
>> Rick Frankel <address@hidden> 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
Thanks a lot - I think this should possibly go ito worg?
I'll keep it for reference as I implemented the whole layouting in R.
Thanks,
Rainer
>
>
> rick
>
> Note: previous reply was not to list (whoops) CC'ing the list on this so the
> answer is saved for posterity :).
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,
UCT), Dipl. Phys. (Germany)
Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa
Tel : +33 - (0)9 53 10 27 44
Cell: +33 - (0)6 85 62 59 98
Fax : +33 - (0)9 58 10 27 44
Fax (D): +49 - (0)3 21 21 25 22 44
email: address@hidden
Skype: RMkrug
PGP: 0x0F52F982
signature.asc
Description: PGP signature