Search code examples
rlatexstargazer

Stargazer not publishing regression table


The packages I currently have downloaded are: tinytex, stargazer, and rmarkdown.

I have used this function to create a publishable table:

stargazer(EB734_May_2010_model_u)

But got this instead:

% Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu
% Date and time: Wed, Sep 02, 2020 - 09:30:46
\begin{table}[!htbp] \centering 
  \caption{} 
  \label{} 
\begin{tabular}{@{\extracolsep{5pt}}lc} 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & \multicolumn{1}{c}{\textit{Dependent variable:}} \\ 
\cline{2-2} 
\\[-1.8ex] & trust \\ 
\hline \\[-1.8ex] 
 D\_economy2 & $-$0.220$^{*}$ \\ 
  & (0.119) \\ 
  & \\ 
 D\_economy0 & 0.243$^{**}$ \\ 
  & (0.118) \\ 
  & \\ 
 E\_economy2 & $-$0.166 \\ 
  & (0.112) \\ 
  & \\ 
 E\_economy0 & $-$0.168 \\ 
  & (0.112) \\ 
  & \\ 
 Support\_EMU0 & 0.655$^{***}$ \\ 
  & (0.027) \\ 
  & \\
 Constant & $-$2.038$^{***}$ \\ 
  & (0.148) \\ 
  & \\ 
\hline \\[-1.8ex] 
Observations & 18,282 \\ 
Log Likelihood & $-$22,543.580 \\ 
Akaike Inf. Crit. & 45,141.170 \\ 
\hline 
\hline \\[-1.8ex] 
\textit{Note:}  & \multicolumn{1}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
\end{tabular} 
\end{table} 

I need to publish the summary for my logistic regression model into word from R.

Any idea on how to fix this? Thanks. :)


Solution

  • The easiest way would be:

    stargazer(EB734_May_2010_model_u, type = "text")
    

    which will give you output in text form that you can use immediately.

    Alternatively, if you want a good-looking HTML table that you can then paste into Word:

    stargazer(EB734_May_2010_model_u, out = "output.html")
    

    Don't worry if your Rmd shows a lot of code below as output, just go into your working directory after you run it, and look for a file called "output.html". You should be able to open that with Word, and then copy and paste into your document.