emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Merge tables
@ 2009-08-19 16:08 Hector Villafuerte
  2009-08-19 16:16 ` Bernt Hansen
  0 siblings, 1 reply; 4+ messages in thread
From: Hector Villafuerte @ 2009-08-19 16:08 UTC (permalink / raw)
  To: emacs-orgmode

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?

By the way, thanks for this great piece of software!
-- 
 hector

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Merge tables
  2009-08-19 16:08 Merge tables Hector Villafuerte
@ 2009-08-19 16:16 ` Bernt Hansen
  2009-09-28 20:31   ` Dan Davison
  0 siblings, 1 reply; 4+ messages in thread
From: Bernt Hansen @ 2009-08-19 16:16 UTC (permalink / raw)
  To: Hector Villafuerte; +Cc: emacs-orgmode

Hector Villafuerte <hectorvd@gmail.com> 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?

Rectangular cut and paste maybe?

-Bernt

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: Merge tables
  2009-08-19 16:16 ` Bernt Hansen
@ 2009-09-28 20:31   ` Dan Davison
  2009-09-29 15:15     ` Darlan Cavalcante Moreira
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Davison @ 2009-09-28 20:31 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode

Bernt Hansen <bernt@norang.ca> writes:

> Hector Villafuerte <hectorvd@gmail.com> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: Merge tables
  2009-09-28 20:31   ` Dan Davison
@ 2009-09-29 15:15     ` Darlan Cavalcante Moreira
  0 siblings, 0 replies; 4+ messages in thread
From: Darlan Cavalcante Moreira @ 2009-09-29 15:15 UTC (permalink / raw)
  To: Dan Davison; +Cc: Bernt Hansen, emacs-orgmode

At Mon, 28 Sep 2009 16:31:22 -0400,
Dan Davison wrote:
> 
> Bernt Hansen <bernt@norang.ca> writes:
> 
> > Hector Villafuerte <hectorvd@gmail.com> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-09-29 17:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-19 16:08 Merge tables Hector Villafuerte
2009-08-19 16:16 ` Bernt Hansen
2009-09-28 20:31   ` Dan Davison
2009-09-29 15:15     ` Darlan Cavalcante Moreira

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).