2

I have a very basic Rstudio regression output table inputing in Latex issue. I get an error message pointing me to the end of the frame part, after the table and I can't see what's wrong. Here is the code I am using.

\documentclass{beamer}
\usepackage{graphicx}
\usepackage{amsmath,amsthm,relsize}

\begin{document}
\title{Formative work2}   
\author{Antoine Zerbini} 
\date{\today} 

\frame{\titlepage} 

\frame{\frametitle{Table of contents}\tableofcontents} 


\section{Section no.1} 
\frame{\frametitle{Title} 
Each frame should have a title.
}
\subsection{Subsection no.1.1  }
\frame{ 
Without title somethink is missing. 
}


\section{Section no. 2} 
\subsection{Lists I}
\frame{\frametitle{unnumbered lists}

\begin{table}[!htbp] \centering 
  \caption{Results FX} 
  \label{} 

\begin{tabular}{@{\extracolsep{5pt}}lD{.}{.}{-3} D{.}{.}{-3} } 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & \multicolumn{2}{c}{\textit{Dependent variable:}} \\ 
\cline{2-3} 
\\[-1.8ex] & \multicolumn{2}{c}{StudentSatisfaction} \\ 
\\[-1.8ex] & \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)}\\ 
\hline \\[-1.8ex] 
 StudentStaffRatio & 0.413^{***} & 0.412^{***} \\ 
  & (0.061) & (0.061) \\ 
  & & \\ 
 controls.rank &  & -0.0003^{*} \\ 
  &  & (0.0002) \\ 
  & & \\ 
\hline \\[-1.8ex] 
Observations & \multicolumn{1}{c}{1,002} & \multicolumn{1}{c}{1,002} \\ 
R$^{2}$ & \multicolumn{1}{c}{0.048} & \multicolumn{1}{c}{0.051} \\ 
Adjusted R$^{2}$ & \multicolumn{1}{c}{-0.048} & \multicolumn{1}{c}{-0.046} \\ 
F Statistic & \multicolumn{1}{c}{45.943$^{***}$ (df = 1; 909)} & \multicolumn{1}{c}{24.388$^{***}$ (df = 2; 908)} \\ 
\hline 
\hline \\[-1.8ex] 
\textit{Note:}  & \multicolumn{2}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
\end{tabular} 
\end{table} }

\end{document}
  • 1
    Welcome to TeX.SE! May it be that you just removed some style files from the file produced by RStudio? – marmot Mar 17 '18 at 23:33
  • Thank you @marmot! I don't think so. I copy pasted the output from stargazer. I could have added the first 3 lines of comments starting by % but that makes no difference – unisateur Mar 17 '18 at 23:37
1

The source of your problem is a missing \usepackage{dcolumn}.

Some other comments:

  • you don't need graphicx with beamer

  • \author{}, \title{} etc. should, if possible, be used before \begin{document}

  • better use \begin{frame}...\end{frame} instead of \frame{}

  • defining an empty \label{} does not make sense

  • your table has lots of empty lines and manual spaces, instead of these hacks use the booktabs package to get better spacing in your table.

  • with the default beamer font size, your table was too big for a single frame, I choose a smaller font size instead. Even better would be to change the layout of the table. The columns 2 and 3 are unnecessary wide because of the last row.

  • because of the excessive use of \multicolumn, some of the minus sigs where typeset as -

  • the rapid changing between math mode and text mode messed up the spacing for the equations in from the "note"

  • I don't know much about the dcolumn package, but please check the used options for the alignment, it looks off. (personally I prefer the siunitx package to align numbers in columns, see Formatting table with siunitx: problem with parentheses and signs on how to align statistic tables)

Moral of the story: automatically produced code is ugly and needs manual adjustments. Don't just use it as it is.

An attempt to clean the code up a bit (some of the \multicolumn are still unnecessary):

\documentclass{beamer}
%\usepackage{graphicx}
\usepackage{amsmath,amsthm,relsize}

\title{Formative work2}   
\author{Antoine Zerbini} 
\date{\today} 

\usepackage{dcolumn}
\usepackage{booktabs}

\begin{document}

\begin{frame}
  \frametitle{unnumbered lists}

  \begin{table}
    \centering 
    \caption{Results FX} 
    %  \label{} 
    \small
    \begin{tabular}{@{}lD{.}{.}{-3} D{.}{.}{-3}@{}} 
      \toprule
      & \multicolumn{2}{c}{\textit{Dependent variable:}}\\
      \cmidrule{2-3}
      & \multicolumn{2}{c}{StudentSatisfaction}\\
      & \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)}\\ 
      \midrule
      StudentStaffRatio & 0.413^{***} & 0.412^{***} \\ 
      & (0.061) & (0.061) \\ \addlinespace
      controls.rank &  & -0.0003^{*} \\ 
      &  & (0.0002) \\ 
      \midrule
      Observations & \multicolumn{1}{c}{1,002} & \multicolumn{1}{c}{1,002} \\
      R$^{2}$ & 0.048 & 0.051 \\
      Adjusted R$^{2}$ & -0.048 & -0.046 \\ 
      F Statistic & \multicolumn{1}{c}{45.943$^{***}$ (df = 1; 909)} & \multicolumn{1}{c}{24.388$^{***}$ (df = 2; 908)} \\ 
      \bottomrule
      \textit{Note:}  & \multicolumn{2}{r}{$^{*}p<0.1$; $^{**}p<0.05$; $^{***}p<0.01$} \\ 
\end{tabular} 
\end{table}
\end{frame}

\end{document}

enter image description here

  • Many thanks for the answer and the detailed comments @samcarter! – unisateur Mar 18 '18 at 12:36
  • @unisateur You're welcome! – user36296 Mar 18 '18 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.