[R] ftable as latex (with Hmisc?)

Frank E Harrell Jr f.harrell at vanderbilt.edu
Mon Nov 26 18:15:53 CET 2007


Dieter Menne wrote:
> Dear List, possibly called Frank,
> 
> 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.

See if fun=table (no quotes) or method='cross' work for you.
Frank

> 
> Other suggestions welcome. Note that in the output there should be empty fields
> on repeated column values like ftable produces.
> 
> Dieter
> 
> 
> #---------------------------------------
> library(Hmisc)
> 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)
> 
> ______________________________________________
> R-help at 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.
> 


-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University



More information about the R-help mailing list