Skip to content

latex of ftable (Hmisc?)

3 messages · Dieter Menne, Chuck Cleland

#
Dear latexRs,

I tried to make a latex printout of a simple categorial ftable. It should
look like the output of print.ftable. Any ideas how to get the syntax of
summary.formula right. Or some alternative? As far I see, xtable does not
have method for ftable.

Dieter


library(Hmisc)
n=500
sex <- factor(sample(c("m","f"), n, rep=TRUE))
treatment <- factor(sample(c("Drug","Placebo"), n, rep=TRUE))
symptom <- factor(sample( c('H','S','G'), n,TRUE))
# I want this output in latex
ftable(symptom~treatment+sex)
# No, it's not the same
ss = summary(symptom~treatment+sex,fun=table)
latex(ss)
#
Dieter Menne wrote:
How about a Sweave approach?  Something like this in the *.Rnw file:

\documentclass[letter]{article}

\begin{document}

@

<<echo=FALSE,print=FALSE>>=

library(Hmisc)
n=500
sex <- factor(sample(c("m","f"), n, rep=TRUE))
treatment <- factor(sample(c("Drug","Placebo"), n, rep=TRUE))
symptom <- factor(sample( c('H','S','G'), n,TRUE))

@

<<echo=TRUE,print=TRUE>>=

ftable(symptom ~ treatment + sex)

@

\end{document}

  Then Sweave() the *.Rnw file to produce a *.tex file in the working
directory.

  
    
#
Chuck Cleland <ccleland <at> optonline.net> writes:
...
Well, this IS for Sweave, and I currently use that solution as a surrogate, but
it definitively not a good looking table for a report.

Dieter