Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escaping special characters with etable. #15

Closed
dlindzee opened this issue Feb 7, 2020 · 1 comment
Closed

Escaping special characters with etable. #15

dlindzee opened this issue Feb 7, 2020 · 1 comment

Comments

@dlindzee
Copy link

@dlindzee dlindzee commented Feb 7, 2020

Hi and thanks for such an amazing package. There seems to be an issue with escaping special characters in the etable function when the TEX option is set to true.

#Load the libraries
library(data.table)
library(fixest)

#Set the seed
set.seed(1)
 
X <- rep(c(1,1,2,3), 10) + rnorm(10*4,0,1)
a = rep(c("b","b","a", "c"), 10)
Y = rep(c(3,3,2,1.1), 10) + 0.5*X + rnorm(10*4,0,0.01)

#Create the data
DT = data.table(
  ID_var = a,
  Y,
  X
)

#Some regressions
Reg_1 <- feols(Y~X, DT)
Reg_2 <- feols(Y~X|ID_var, DT)

#Export the regressions
etable(Reg_1, Reg_2, tex = TRUE, fixef_sizes = T, se = "cluster", cluster = "ID_var")

I receive the following output.

\begin{table}[htbp]\centering
\caption{no title}
\begin{tabular}{lcc}
 & & \tabularnewline
\hline
\hline
Dependent Variable:&\multicolumn{2}{c}{Y}\\
Model:&(1)&(2)\\
\hline
\emph{Variables}\tabularnewline
(Intercept)&3.1110$^{***}$&  \\
  &(0.2996)&  \\
X&0.0468&0.5024$^{***}$\\
  &(0.0975)&(0.0023)\\
\hline
\emph{Fixed-Effects}&  & \\
ID\_var&No&Yes\\
\hline
\emph{Fit statistics}&  & \\
Observations& 40&40\\
# ID\_var&--&3\\
R$^2$ & 0.01063&0.99975\\
Within R$^2$ & --&0.99958\\
\hline
\hline
\multicolumn{3}{l}{\emph{One-way (ID_var) standard-errors in parentheses.}}\\
\multicolumn{3}{l}{\emph{Signif Codes: ***: 0.01, **: 0.05, *: 0.1}}\\
\end{tabular}
\end{table}

Notice that ID_var in the clustered error variable in the fourth last line of the table should be escaped as ID\_var. More importantly the # in the fit statistics section of the table, under the Observations variable, also not escaped. This bug persists even if one supplies a file instead of setting tex = TRUE.

Thanks again.

@lrberge
Copy link
Owner

@lrberge lrberge commented Feb 7, 2020

Thanks @dlindzee !

I thought I had got rid of all escaping problems... but they are still lurking around the corner!
I've fixed this in the dev version. Hopefully we should get closer!

Thanks again for the report!

@lrberge lrberge closed this Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.