fixest icon indicating copy to clipboard operation
fixest copied to clipboard

header generates NA in latex table

Open YH244511 opened this issue 1 year ago • 1 comments

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!

YH244511 avatar Oct 21 '22 02:10 YH244511

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)

Oravishayrizi avatar Mar 13 '23 08:03 Oravishayrizi