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

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Fri 27 Oct 2006 - 22:25:38 GMT

Serguei Kaniovski <kaniovsk@wsr.ac.at> writes:

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

Explain. If tab1 and tab2 have names "in the first column", how do you expect the divide operation to work? Tables normally do preserve row/column names in arithmetic:

> t1 <- t2 <- table(airquality$Month,airquality$Temp> 80)
> t1

    FALSE TRUE
  5 30 1
  6 20 10
  7 3 28
  8 11 20
  9 21 9
> t1/t2

    FALSE TRUE

  5     1    1
  6     1    1
  7     1    1
  8     1    1
  9     1    1


-- 
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat Oct 28 08:30:42 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 Fri 27 Oct 2006 - 23:30:14 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.