0

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

zx8754
  • 52,746
  • 12
  • 114
  • 209
Syzorr
  • 587
  • 1
  • 5
  • 17

1 Answers1

4

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)
Koundy
  • 5,265
  • 3
  • 24
  • 37
  • Works perfectly for TukeyHSD but getting an error for model.table for the same reason xtable was failing before: "cannot coerce class "c("tables_aov", "list.of")" to a data.frame" – Syzorr May 11 '16 at 07:06
  • some how you have to convert model.table object to a data.frame. I dnt know exactly how but this [https://cran.r-project.org/web/packages/RMark/RMark.pdf] package might help – Koundy May 11 '16 at 07:11
  • Still not working but the only reason I was using it at all was to pad out the analysis with everything we'd covered. Figuring Tukey's meets exactly what the model.tables was attempting to. Thanks! – Syzorr May 11 '16 at 08:32