On Aug 30, 2011, at 10:04 , Luca Meyer wrote:
Hi,
Does anyone know how to show zero frequencies variable levels with the xtabs command? They show with the table(x,y) command but I need to apply weight to frequency tables and I also need to cbind several tables together, which implies that they all need to show the same number of rows.
Are you sure you are doing the same thing as with table(). I'd expect it to work if you ensure that the variables are factors:
library(ISwR)
xtabs(~sex+menarche,data=juul)
menarche
sex 1 2
2 369 335
juul$sex <- factor(juul$sex,levels=1:2)
xtabs(~sex+menarche,data=juul)
menarche
sex 1 2
1 0 0
2 369 335
Alternatively, do you know how to column bind tables with different number of rows? I cannot use merge as it requires daata.frame and that modifies the look of the banner table I am trying to create...
Thanks,
Luca
Mr. Luca Meyer
www.lucameyer.com
R version 2.13.1 (2011-07-08)
Mac OS X 10.6.8
[[alternative HTML version deleted]]