How can you export a regression table from r with etable and without the table environment?

912 views Asked by At

Is there a way to export a regression table from r with the etable function (from the "fixest" package) without the table environment? Hence, the latex code should not start with \begin{table} but with \begin{tabular}.

I know that it is possible with xtable and stargazer, but what about etable?

2

There are 2 answers

0
Laurent Bergé On BEST ANSWER

By default, the table environment is not present in etable's Latex exports unless there is a caption. This is very likely a package version problem.

Here is a MRE with fixest 0.10.4:

base = setNames(iris, c("y", "x1", "x2", "x3", "species"))
est = feols(y ~ csw(x.[,1:3]), base)

etable(est, tex = TRUE)
#> \begingroup
#> \centering
#> \begin{tabular}{lccc}
#>    \tabularnewline \midrule \midrule
#>    Dependent Variable: & \multicolumn{3}{c}{y}\\
#>    Model:         & (1)           & (2)            & (3)\\  
#>    \midrule
#>    \emph{Variables}\\
#>    (Intercept)    & 6.526$^{***}$ & 2.249$^{***}$  & 1.856$^{***}$\\   
#>                   & (0.4789)      & (0.2480)       & (0.2508)\\   
#>    x1             & -0.2234       & 0.5955$^{***}$ & 0.6508$^{***}$\\   
#>                   & (0.1551)      & (0.0693)       & (0.0667)\\   
#>    x2             &               & 0.4719$^{***}$ & 0.7091$^{***}$\\   
#>                   &               & (0.0171)       & (0.0567)\\   
#>    x3             &               &                & -0.5565$^{***}$\\   
#>                   &               &                & (0.1275)\\   
#>    \midrule
#>    \emph{Fit statistics}\\
#>    Observations   & 150           & 150            & 150\\  
#>    R$^2$          & 0.01382       & 0.84018        & 0.85861\\  
#>    Adjusted R$^2$ & 0.00716       & 0.83800        & 0.85571\\  
#>    \midrule \midrule
#>    \multicolumn{4}{l}{\emph{IID standard-errors in parentheses}}\\
#>    \multicolumn{4}{l}{\emph{Signif. Codes: ***: 0.01, **: 0.05, *: 0.1}}\\
#> \end{tabular}
#> \par\endgroup
0
samcarter_is_at_topanswers.xyz On

You could let latex add your note at the end of the table environment:

\documentclass{article}

\begin{document}

\AddToHook{env/table/end}{some note}

\begin{table}
first table
\end{table}

\RemoveFromHook{env/table/end}

\begin{table}
second table
\end{table}

\end{document}