The trick for latexing glht objects is recognizing that they are very complex.
It is necessary to isolate the part you want first,
then the latex() function in Hmisc works very well.
This example is based on one of the examples in ?glht
library(Hmisc)
library(multcomp)
### set up a one-way ANOVA
amod <- aov(breaks ~ tension, data = warpbreaks)
### set up all-pair comparisons for factor `tension'
### using a symbolic description (`type' argument
### to `contrMat()')
amod.glht <- glht(amod, linfct = mcp(tension = "Tukey"))
latex(confint(amod.glht)$confint, dec=3)
Look at
str(amod.glht)
str(confint(amod.glht))
multcomp:::print.glht
multcomp:::print.confint.glht
to see the details.
Rich
On Sat, Oct 12, 2013 at 9:33 AM, Winter, Jan-Christoph
<j.winter at tu-berlin.de> wrote:> Hi,
>
> I want to export the result of glht in R into a LaTeX table, such as that
result:
>
> Linear Hypotheses:
> Estimate Std. Error z value
Pr(>|z|)
> Group1 - Group2 == 0 -0.14007 0.01589 -8.813 <0.001
"***"
> Group1 - Group3 == 0 -0.09396 0.01575 -5.965 <0.001 ***
> ---
> Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
> (Adjusted p values reported -- single-step method)
>
> I'm aware of libraries like stargazer, xtable, texreg, reporttools,
memisc and apsrtable, but none of them does the job for glht :(
>
> Does anyone have any hints?
>
> Thanks and best regards
> Jan Winter
> ______________________________________________
> 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.