* Combine tables which are results from calculations? @ 2015-11-03 13:18 Rainer M Krug [not found] ` <20151103202732.GA10994@eyeBook.home> 0 siblings, 1 reply; 3+ messages in thread From: Rainer M Krug @ 2015-11-03 13:18 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1374 bytes --] Hi Considering the following example: --8<---------------cut here---------------start------------->8--- #+NAME t1 #+begin_src R :colnames yes data.frame(a = 1:3) #+end_src #+RESULTS: | a | |---| | 1 | | 2 | | 3 | #+NAME t2 #+begin_src R :colnames yes data.frame(b = 1:10) #+end_src #+RESULTS: | b | |----| | 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | | 9 | | 10 | #+NAME t3 #+begin_src R :colnames yes data.frame(c = 1:7) #+end_src #+RESULTS: | c | |---| | 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | What I would like to have is: | a | b | c | |----|----|----| | 1 | 1 | 1 | | 2 | 2 | 2 | | 3 | 3 | 3 | | | 4 | 4 | | | 5 | 5 | | | 6 | 6 | | | 7 | 7 | | | 8 | | | | 9 | | | | 10 | | --8<---------------cut here---------------end--------------->8--- How can I combine t1, t2 and t3 column wise? Thanks, Rainer -- 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: Rainer@krugs.de Skype: RMkrug PGP: 0x0F52F982 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 454 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <20151103202732.GA10994@eyeBook.home>]
[parent not found: <m2oafa3zm3.fsf@krugs.de>]
* Re: Combine tables which are results from calculations? [not found] ` <m2oafa3zm3.fsf@krugs.de> @ 2015-11-04 17:50 ` Rick Frankel 2015-11-05 8:20 ` Rainer M Krug 0 siblings, 1 reply; 3+ messages in thread From: Rick Frankel @ 2015-11-04 17:50 UTC (permalink / raw) To: Rainer M Krug; +Cc: emacs-orgmode 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 :). ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Combine tables which are results from calculations? 2015-11-04 17:50 ` Rick Frankel @ 2015-11-05 8:20 ` Rainer M Krug 0 siblings, 0 replies; 3+ messages in thread From: Rainer M Krug @ 2015-11-05 8:20 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1980 bytes --] Rick Frankel <rick@rickster.com> writes: > 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 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: Rainer@krugs.de Skype: RMkrug PGP: 0x0F52F982 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 454 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-11-05 8:20 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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 2015-11-05 8:20 ` Rainer M Krug
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).