I'm dealing with ANOVA tables which I am outputting in my R Markdown using xtable
and outputting to PDF.
However, when I'm using functions like TukeyHSD
or model.tables
to do comparative analysis, xtable
is giving me the error (in the case of model.tables
):
Error in UseMethod("xtable") : no applicable method for 'xtable' applied to an object of class "c('tables_aov', 'list.of')"
How do I get around this?
I'm trying to find a way to output these in a way that isn't just basic R output but I'm running in to this problem with any of the other packages like texreg
or stargazer
There is a package called broom
which will convert your model results into a data.frame. A reproducible example from package documentation. You can use xtable
on the dataframe object
> library(broom)
> fm1 <- aov(breaks ~ wool + tension, data = warpbreaks)
> thsd <- TukeyHSD(fm1, "tension", ordered = TRUE)
> tidy(thsd)
comparison estimate conf.low conf.high adj.p.value
1 M-H 4.722222 -4.6311985 14.07564 0.447421021
2 L-H 14.722222 5.3688015 24.07564 0.001121788
3 L-M 10.000000 0.6465793 19.35342 0.033626219)