I intend to have the result of a logit regression in a nicely formatted table in R. so, I use library(xtable) with print(xtable) function. The result came out in a LaTex document that didn't look "nicely formatted" Any advice on how I could achieve this?
library(xtable)
print(xtable(art1glm))
LaTex Code (result in R)
% latex table generated in R 3.6.1 by xtable 1.8-4 package
% Fri May 08 07:54:12 2020
\begin{table}[ht]
\centering
\begin{tabular}{rrrrr}
\hline
& Estimate & Std. Error & z value & Pr($>$$|$z$|$) \\
\hline
(Intercept) & -7.4517 & 2.0323 & -3.67 & 0.0002 \\
clinton\_vote & 0.1660 & 0.0418 & 3.97 & 0.0001 \\
year\_term\_ends2002 & 0.2660 & 0.5672 & 0.47 & 0.6391 \\
year\_term\_ends2004 & 0.4100 & 0.5675 & 0.72 & 0.4699 \\
first\_term1 & -1.0050 & 0.4819 & -2.09 & 0.0370 \\
\hline
\end{tabular}
\end{table}
I also tried to write the result to a .tex file, didn't work also as pdfLetex gave "!LaTeX Error: Environment table undefined.
This works for me. You could try to replicate my example and see whether it works. If it does, try again but with your regression instead of the filename tex. If also this works, there must be something wrong with your latex document file.
R code with regression
library(xtable)
data("infert")
m <- glm(case ~ spontaneous+induced, data = infert, family = binomial())
print(xtable(m), file = "filename.tex", compress = FALSE)
Latex code:
\documentclass[12pt]{article}
\begin{document}
\input{filename.tex}
\end{document}
Also, you could check out stargazer https://cran.r-project.org/web/packages/stargazer/vignettes/stargazer.pdf