> Dieter Menne wrote: >> I tried to create an ftable lookalike of the following data set in >> LaTeX/Sweave >> with summary(formula,..), but I could not get it to work for count tables; >> numeric tables work fine. >> > > summary(formula,...,fun="table") does not give the full cross breakdown. >
Frank E Harrell Jr <f.harrell <at> vanderbilt.edu> writes: > See if fun=table (no quotes) or method='cross' work for you. > Frank > No, it does not, that's why I asked. I had tried both, fun=table (with or without "") give a individual breakdown by factor, and method="cross" an error message (works find with numerical data). Dieter > df = data.frame(drug=sample(c("P","V"),100,TRUE), + Hist1=sample(c("Pos","Neg"),100,TRUE), + Hist2=sample(c("Pos","Neg"),100,TRUE)) > ftable(drug~Hist1+Hist2,data=df) drug P V Hist1 Hist2 Neg Neg 14 6 Pos 11 14 Pos Neg 13 15 Pos 14 13 > summary(drug~Hist1+Hist2,data=df,fun=table) drug N=100 +-------+---+---+--+--+ | | |N |P |V | +-------+---+---+--+--+ |Hist1 |Neg| 45|25|20| | |Pos| 55|27|28| +-------+---+---+--+--+ |Hist2 |Neg| 48|27|21| | |Pos| 52|25|27| +-------+---+---+--+--+ |Overall| |100|52|48| +-------+---+---+--+--+ > summary(drug~Hist2+Hist2,data=df,method="cross") Error in Y %*% rep(1, ncol(Y)) : requires numeric matrix/vector arguments In addition: Warning message: In mean.default(newX[, i], ...) : argument is not numeric or logical: returning NA > > ______________________________________________ R-help@r-project.org 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.