[R] Bug in ftable?? (Was: Two-way tables of data, etc)

BXC (Bendix Carstensen) bxc at novonordisk.com
Wed Sep 5 10:50:57 CEST 2001


Further to the discussion between Murray Jorgensen and Brian Ripley,
it seems to me better to choose tabulations that will not come and bite
you. Suppose your data are sligtly irregular, e.g. (for the sake of
the argument):

data( warpbreaks )
warpbreaks$variant <- rep( 1:5, len=54 )
attach( warpbreaks )
tb <- table( wool, tension, variant )
tb

# in this case you would like to see:

tp <- tapply( breaks, list( wool, tension, variant ), mean )
tp

# and hardly:
ftable( xtabs( breaks ~ wool + tension + variant ) )

# It would be nice to flatten the tabulations, so I tried:
ftable( tb )

tp <- as.table( tp )
ftable( tp )

But here i get:

> attr( tp, "class" ) <- "table"
> ftable( tp )
Error in cbind(...) : number of rows of matrices must match (see arg 2)

# But still they seem to have similar attributes (except for the naming)
attributes( tb )
attributes( tp )

Is this a bug or a facility of ftable ?

Bendix Carstensen

----------------------
Bendix Carstensen
Senior Statistician
Steno Diabetes Centre
Niels Steensens Vej 2
DK-2820 Gentofte
Denmark
tel: +45 44 43 87 38
mob: +45 28 25 87 38
fax: +45 44 43 73 13
bxc at novo.dk
www.biostat.ku.dk/~bxc
----------------------


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list