[R] How to best divide table by table
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Sat Oct 28 00:25:38 CEST 2006
Serguei Kaniovski <kaniovsk at 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 at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list