0

Whenever I tried to make a pdf document, this issue occurred. How could I deal with this? I'm very embarrassed by the problem!

\begin{table}[!htbp] \centering 
  \caption{Comparison of Regression Results} 
  \label{} 
\begin{tabular}{@{\extracolsep{5pt}}lD{.}{.}{-3} D{.}{.}{-3} D{.}{.}{-3} } 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & \multicolumn{3}{c}{\textit{Dependent variable:}} \\ 
\cline{2-4} 
\\[-1.8ex] & \multicolumn{3}{c}{Corruption} \\ 
\\[-1.8ex] & \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)} & \multicolumn{1}{c}{(3)}\\ 
\hline \\[-1.8ex] 
 GDP per capita & 0.0002^{***}$ $(0.0002$, $0.0002) &  &  \\ 
  GDP per capita (Squred) &  & 0.000^{***}$ $(0.000$, $0.000) &  \\ 
  GDP per capital (Log) &  &  & 1.431^{***}$ $(1.255$, $1.606) \\ 
  Constant & 2.502^{***}$ $(2.259$, $2.746) & 3.413^{***}$ $(3.154$, $3.671) & -8.114^{***}$ $(-9.621$, $-6.607) \\ 
 \hline \\[-1.8ex] 
Observations & \multicolumn{1}{c}{170} & \multicolumn{1}{c}{170} & \multicolumn{1}{c}{170} \\ 
\hline 
\hline \\[-1.8ex] 
\textit{Note:}  & \multicolumn{3}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
\end{tabular} 
\end{table} 

ADD Syntax

library(stargazer)
stargazer(q4_fit, q4_fit_squred, q4_g_log, type="latex",
          title ="Comparison of Regression Results", align=TRUE, 
          dep.var.labels="Corruption",
          covariate.labels=c("GDP per capita", "GDP per capita (Squred)", "GDP per capital (Log)"),
          keep.stat="n", ci=TRUE, ci.level=0.95, single.row=TRUE)
1
  • the actual error message would say which character was illegal, presumably D which is not a standard column type. You have not provided an example that produces the error but perhaps you are missing \usepackage{dcolumn} – David Carlisle Mar 3 at 22:09
0

The error messags is due to the array column specifier D which you have used and not defined (I guess as you neither showed the full error or a test document)

You are using the syntax of the dcolumn package and simply loading that package makes the error go away although the -3 specification makes very wide table here that is unlikely to fit your (unspecified) page size.

I guess you want something like

enter image description here

\documentclass{article}

\usepackage{dcolumn,rotating}

\begin{document}

\begin{sidewaystable} \centering 
  \caption{Comparison of Regression Results} 
  \label{} 
\begin{tabular}{lD{.}{.}{1.7}l D{.}{.}{1.7}l D{.}{.}{1.7}l } 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & \multicolumn{6}{c}{\textit{Dependent variable:}} \\ 
\cline{2-7} 
\\[-1.8ex] & \multicolumn{6}{c}{Corruption} \\ 
\\[-1.8ex] & \multicolumn{2}{c}{(1)} & \multicolumn{2}{c}{(2)} & \multicolumn{1}{c}{(3)}\\ 
\hline \\[-1.8ex] 
 GDP per capita & 0.0002^{***}& (0.0002, 0.0002) & & &&  \\ 
  GDP per capita (Squared) & & & 0.000^{***}&(0.000, 0.000) &&  \\ 
  GDP per capital (Log) & & & & & 1.431^{***}&(1.255, 1.606) \\ 
  Constant & 2.502^{***}&(2.259, 2.746) & 3.413^{***}&(3.154, 3.671) & -8.114^{***}&(-9.621, -6.607) \\ 
 \hline \\[-1.8ex] 
Observations & \multicolumn{2}{c}{170} & \multicolumn{2}{c}{170} & \multicolumn{2}{c}{170} \\ 
\hline 
\hline \\[-1.8ex] 
\textit{Note:}  & \multicolumn{4}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
\end{tabular} 
\end{sidewaystable}
\end{document}

1
  • @CSKim It's better to ask new questions as new questions, instead of followups hiding in comments. The preamble is everything that comes before \begin{document}. The \usepackage command can only be used there. – Teepeemm Mar 4 at 3:04

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.