Re: [R] How to best divide table by table

From: Martin Maechler <>
Date: Mon 30 Oct 2006 - 09:08:31 GMT

But *please* do learn from Peter Dalgaard's answer that this has nothing to do with "table"s (Petr, I agree you have "helped" Serguei, but...)

Using vague language is not helpful in such contexts. And hence, calling data frames 'tab1' is probably not a good idea.
{Calling them 'data' is not much better though:

  > fortune("dog")

  Firstly, don't call your matrix 'matrix'. Would you call your dog 'dog'?   Anyway, it might clash with the function 'matrix'.

Martin Maechler

>>>>> "Petr" == Petr Pikal <> >>>>> on Mon, 30 Oct 2006 08:12:57 +0100 writes:

    Petr> Hi Assuming the same order in both tables divide only
    Petr> columns you wont and then add column of names. You
    Petr> need to work with data frame, as working with matrices
    Petr> cannot use mixed types columns.

    Petr> tab1<-data.frame(letters[1:3], 1:3)
    Petr> tab2<-data.frame(letters[1:3], 10)
    Petr> data.frame(tab1[,1],tab1[,-1]/tab2[,-1])
    Petr> tab1...1. tab1....1..tab2....1. 1 a 0.1 2 b 0.2 3 c     Petr> 0.3

    Petr> How to set appropriate column names you can find in     Petr> help page ?data.frame  

    Petr> HTH Petr

    Petr> On 27 Oct 2006 at 18:42, Serguei Kaniovski wrote:

    Petr> Date sent: Fri, 27 Oct 2006 18:42:36 +0200 (CEST)
    Petr> From: Serguei Kaniovski <> To:
    Petr> Organization: WIFO Subject:
    Petr> [R] How to best divide table by table

>> Hi all,
>> how can I divide two tables of the same dimension so that
>> all names are preserved, ie do not become NA? I have
>> "tab1" and "tab2", each having names in the first
>> column. I want "tab3" with the same names and values
>> "tab1/tab2".
>> Thanks, Serguei mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Mon Oct 30 20:22:45 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 30 Oct 2006 - 09:30:14 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.