0

In a table produced by the texreg::texreg() function in R I want to replace numerical values with strings. The purpose is to summarize values of a bunch of control variables with a single line and a simple "yes".

My problem is that the yeses aren't centered. So my idea was to add some white-space before but it won't work with any method I know. Probably it'll be removed somehow.

This is the original line to be modified.

groupTrt    & -0.37      \\
            & (0.31)     \\

And this is my code:

\usepackage{dcolumn}
\begin{table}
\begin{center}
\begin{tabular}{l D{.}{.}{2.5} }
\hline
 & \multicolumn{1}{c}{Model 1} \\
\hline
(Intercept) & 5.03^{***} \\
            & (0.22)     \\
Controls    &   \quad yes   \\
Controls    &   ~yes   \\
\hline
R$^2$       & 0.07       \\
Adj. R$^2$  & 0.02       \\
Num. obs.   & 20         \\
RMSE        & 0.70       \\
\hline
\multicolumn{2}{l}{\scriptsize{$^{***}p<0.001$, $^{**}p<0.01$, $^*p<0.05$}}
\end{tabular}
\caption{Statistical models}
\label{table:coefficients}
\end{center}
\end{table}

But neither \quad nor ~ seems to have an effect:

enter image description here

I also tried \ yes but without success.

My expected output would be something like this (photoshopped):

enter image description here

How do I center my yeses?

Note: Originally I wanted to write an own function using the xtable package that 1. automatically removes selected rows from a former function output, and 2. inserts custom rows with numbers, placeholders or text. Now I'm facing a similar issue with texreg.

2
  • 2
    You can use for example \multicolumn{1}{c}{yes}. I'd also suggest to replace the center environment with the \centering command as the former will add some additional vertical white space when used in combination with table.
    – leandriis
    Oct 7, 2019 at 10:52
  • @leandriis Great, \multicolumn works!! Replacing center environment seems to have no effect, though.
    – jay.sf
    Oct 7, 2019 at 11:10

1 Answer 1

0

As noted by @leandriis in the comments we can use a \multicolumn{1}{c}{yes} within the table.

\begin{table}
\begin{center}
\begin{tabular}{l D{.}{.}{2.5} }
\hline
 & \multicolumn{1}{c}{Model 1} \\
\hline
(Intercept) & 5.03^{***} \\
            & (0.22)     \\
Controls    &  \multicolumn{1}{c}{yes}   \\
\hline
R$^2$       & 0.07       \\
Adj. R$^2$  & 0.02       \\
Num. obs.   & 20         \\
RMSE        & 0.70       \\
\hline
\multicolumn{2}{l}{\scriptsize{$^{***}p<0.001$, $^{**}p<0.01$, $^*p<0.05$}}
\end{tabular}
\caption{Statistical models}
\label{table:coefficients}
\end{center}
\end{table}

Result enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .