0

I'm trying to produce a summary of a logistic regression Analysis of Deviance table, but the result is a block of what I think is LaTex. Here is my code:

m1 <- glm(vote ~ factor(income),
          data = nes1992,
          family = binomial)

xtable(summary(anova(m1)))

The output to the .PDF looks like this:

\begin{table}[ht]
\centering
\begin{tabular}{rrrrr}
  \hline
 & Estimate & Std. Error & z value & Pr($>$$|$z$|$) \\ 
  \hline
(Intercept) & -1.1838 & 0.2087 & -5.67 & 0.0000 \\ 
  factor(income)2 & 0.4906 & 0.2555 & 1.92 & 0.0548 \\ 
  factor(income)3 & 0.7509 & 0.2345 & 3.20 & 0.0014 \\ 
  factor(income)4 & 1.1243 & 0.2312 & 4.86 & 0.0000 \\ 
  factor(income)5 & 1.2378 & 0.3125 & 3.96 & 0.0001 \\ 
   \hline
\end{tabular}
\end{table}

I am working in an .Rmd file and knitting the document to a .PDF file. I'm not sure if I'm doing something wrong or if there is a larger technical issue I need to address. Any help is appreciated.

I updated my code to reflect the documentation requirements, but I'm still getting the unformatted code chunk when I print:

m1table <- xtable(summary(m1))
print(m1table, type = "latex")
samvoit4
  • 295
  • 2
  • 8
  • [`xtable()` converts an R object to an `xtable` object, which can then be printed as a *LaTeX or HTML table*](https://www.rdocumentation.org/packages/xtable/versions/1.8-3/topics/xtable) – nghauran Sep 28 '18 at 21:30
  • @ANG Thanks. I updated the code to reflect the documentation (edits above), but it doesn't seem to have worked... – samvoit4 Sep 28 '18 at 21:40
  • Based on the documentation it seems normal for the output to be in LaTeX – nghauran Sep 28 '18 at 21:43
  • 1
    add `results='asis'` or `results=tex` to your chunk oprtions – user20650 Sep 28 '18 at 23:33

0 Answers0