lrberge / fixest

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

header generates NA in latex table #367

Open YH244511 opened 1 year ago

YH244511 commented 1 year ago

Hi, I found that header ":_:" =list(" "=2, "A"=2, "B"=2) produces NA \cmidrule(lr){4-5} \cmidrule(lr){6-7}

Is there anyway to prevent etable generating "NA" for the first two columns? Thank you!

Oravishayrizi commented 1 year ago

Not the cleanest solution, but you can replace the white space with \phantom{x},

here is a mwe:

library(fixest)

packageVersion("fixest")
#> [1] '0.11.1'

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)

# wo :_: - keeps the whitespace
etable(lm1,lm2,lm3,lm4,
       depvar = FALSE,
       headers= list("_Country"=list(" "=1, "A"=2, "B"=1) ),
       tex=TRUE)

# wo empty space - keeps the whitespace
etable(lm1,lm2,lm3,lm4,
       depvar = FALSE,
       headers= list(":_:Country"=list("a"=1, "A"=2, "B"=1) ),
       tex=TRUE)

# with empty space and :_: - replaces the space with NA 
etable(lm1,lm2,lm3,lm4,
       depvar = FALSE,
       headers= list(":_:Country"=list(" "=1, "A"=2, "B"=1) ),
       tex=TRUE)

# using vphantom - keeps the whitespace
etable(lm1,lm2,lm3,lm4,
       depvar = FALSE,
       headers= list(":_:Country"=list("\\phantom{A}"=1, "A"=2, "B"=1) ),
       tex=TRUE)