[R] zero.print in print.table after adding margins

From: BXC (Bendix Carstensen) <bxc_at_steno.dk>
Date: Thu 29 Jun 2006 - 19:34:41 EST


The function addmargins() adds margins to a table, but returns a matrix. But even after converted to a table the print.zero="." option of print.table() does not work:

> x <- sample( 1:7, 20, replace=T )
> y <- sample( 1:7, 20, replace=T )
> tt <- table( x, y )
> tx <- as.table( addmargins( table( x, y ) ) )
> print( tt, zero.print="." )

   y
x 1 2 3 4 5 6 7

  1 1 2 2 . . 1 .
  2 1 . . 1 . . .
  3 . . . . . . 2
  4 1 . . . . 1 .
  5 1 . 1 . . 1 .
  6 . 1 . 1 . . .

  7 . . 1 . 1 1 .
> print( tx, zero.print="." )
     y
x      1  2  3  4  5  6  7 Sum

  1 1 2 2 0 0 1 0 6
  2 1 0 0 1 0 0 0 2
  3 0 0 0 0 0 0 2 2
  4 1 0 0 0 0 1 0 2
  5 1 0 1 0 0 1 0 3
  6 0 1 0 1 0 0 0 2
  7 0 0 1 0 1 1 0 3
  Sum 4 3 4 2 1 4 2 20

Is this a facility of print.table?
The attributes() of tt and tx have identical stucture.

Best,
Bendix



Bendix Carstensen
Senior Statistician
Steno Diabetes Center
Niels Steensens Vej 2
DK-2820 Gentofte
Denmark
tel: +45 44 43 87 38
mob: +45 30 75 87 38
fax: +45 44 43 07 06

bxc@steno.dk
www.biostat.ku.dk/~bxc

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 Received on Thu Jun 29 19:48:16 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 Thu 29 Jun 2006 - 22:12:35 EST.

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