lrberge / fixest

Fixed-effects estimations
https://lrberge.github.io/fixest/
362 stars 59 forks source link

Can I add cmidrule below the dependent variables in etable? #393

Open Oravishayrizi opened 1 year ago

Oravishayrizi commented 1 year ago

Hi Laurent, Please accept my apologizes if I missed something obvious. When I have few columns with the same dependent variable, the etable I want to have cmidrule below them to make the separation between the dep vars more salient.

Here is a minimal working example:

library(fixest)

lm1<-feols(Sepal.Length~Sepal.Width+Petal.Length|Species,iris)
lm2<-feols(Sepal.Length~Sepal.Width|Species,iris)
lm3<-feols(Sepal.Width~Sepal.Length+Petal.Length|Species,iris)
lm4<-feols(Sepal.Width~Sepal.Length|Species,iris)

# Currently I have to add it manually this way:

etable(lm1,lm2,lm3,lm4,
       depvar = FALSE,
       headers = list(":_:Dependent Variables:"=c("Sepal.Length"=2,"Sepal.Width"=2)),
       tex = TRUE,view = TRUE)

However, It is a hassle to define it each time, and it is quite sensitive to the inclusion or exclusion of models. I guess that one way to do it is by using the postprocess argument, however, I wondered whether there is a better/more efficient way to do it. To fix ideas, I have in mind something like that:

etable(lm1,lm2,lm3,lm4,
       headers = .(":_:"="auto"),
       tex = TRUE,view = TRUE)

Does it even make sense? Is there a way to implement it now?

As always, thank you again for your huge efforts in maintaining and constantly improving this amazing package!