From mboxrd@z Thu Jan 1 00:00:00 1970 From: Darlan Cavalcante Moreira Subject: Re: Re: Merge tables Date: Tue, 29 Sep 2009 12:15:32 -0300 Message-ID: <4ac22497.9653f10a.6433.5abd@mx.google.com> References: <350f72300908190908l61b244dbn66d2f0b045ee9ccf@mail.gmail.com> <871vn7u6cy.fsf@gollum.intra.norang.ca> <87ljjy95gl.fsf@stats.ox.ac.uk> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MsgK2-0004Bp-1X for emacs-orgmode@gnu.org; Tue, 29 Sep 2009 13:17:06 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MsgJw-00047m-LX for emacs-orgmode@gnu.org; Tue, 29 Sep 2009 13:17:05 -0400 Received: from [199.232.76.173] (port=34075 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MsgJv-00047O-J8 for emacs-orgmode@gnu.org; Tue, 29 Sep 2009 13:16:59 -0400 Received: from mx20.gnu.org ([199.232.41.8]:35347) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MsfIS-0007oC-9L for emacs-orgmode@gnu.org; Tue, 29 Sep 2009 12:11:24 -0400 Received: from qw-out-1920.google.com ([74.125.92.150]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MseRT-0001zN-CH for emacs-orgmode@gnu.org; Tue, 29 Sep 2009 11:16:39 -0400 Received: by qw-out-1920.google.com with SMTP id 5so2630835qwc.24 for ; Tue, 29 Sep 2009 08:15:38 -0700 (PDT) In-Reply-To: <87ljjy95gl.fsf@stats.ox.ac.uk> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Dan Davison Cc: Bernt Hansen , emacs-orgmode@gnu.org At Mon, 28 Sep 2009 16:31:22 -0400, Dan Davison wrote: > > Bernt Hansen writes: > > > Hector Villafuerte writes: > > > >> Hi, > >> I've just discovered Org and are truly impressed with it; using it for > >> more and more tasks. > >> > >> Here's what I want to do: I have 2 tables with the same number of rows > >> (one row per subject). I would like to make just one big table by > >> copying the second table to the right of the first one. This is a > >> no-brainer in a spreadsheet but my attempts in Org have failed. Any > >> ideas? > > Hi Hector, > > Here are two ways of doing this in org-babel. > > * Binding tables together by columns > > Suppose the tables are > > #+tblname: tab1 > | 1 | 2 | 3 | > | 7 | 8 | 9 | > > #+tblname: tab2 > | 4 | 5 | 6 | > | 10 | 11 | 12 | > > Here's a solution in emacs lisp: > > #+srcname: column-bind-elisp(a=tab1, b=tab2) > #+begin_src emacs-lisp > (mapcar* 'append a b) > #+end_src > > #+resname: column-bind-elisp > | 1 | 2 | 3 | 4 | 5 | 6 | > | 7 | 8 | 9 | 10 | 11 | 12 | > > And here's a solution in R, which has the advantage that it copes with > column names (and the code is even simpler). > > #+tblname: tab3 > | a | b | c | > |---+---+---| > | 1 | 2 | 3 | > | 7 | 8 | 9 | > > #+tblname: tab4 > | d | e | f | > |----+----+----| > | 4 | 5 | 6 | > | 10 | 11 | 12 | > > #+srcname: column-bind-R(a=tab3, b=tab4) > #+begin_src R :colnames t > cbind(a, b) > #+end_src > > #+resname: column-bind-R > | "a" | "b" | "c" | "d" | "e" | "f" | > |-----+-----+-----+-----+-----+-----| > | 1 | 2 | 3 | 4 | 5 | 6 | > | 7 | 8 | 9 | 10 | 11 | 12 | > > > Once someone has written them, even simple code blocks like these can be > stored in the "library of babel" for users who aren't familiar with a > suitable programming language (I'll add them on worg). > > Dan > > > > > Rectangular cut and paste maybe? > > > > -Bernt > > > > > > _______________________________________________ > > Emacs-orgmode mailing list > > Remember: use `Reply All' to send replies to the list. > > Emacs-orgmode@gnu.org > > http://lists.gnu.org/mailman/listinfo/emacs-orgmode > > > _______________________________________________ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode If you only want to put the second table at the right of the first one I think that the functions kill-rectangle and yank-rectangle are enough. Select the second table (without the first | char) and run the command kill-rectangle (C-x r k), then put the cursor at the end of the first line of the first table and run the command yank-rectangle (C-x r y). -- Darlan Cavalcante Moreira darcamo@gmail.com