I estimate a model with estimatr::lm_robust
and display the model output with modelsummary::modelsummary
. Consider the following example:
df <- tibble(x=runif(100, 0, 100)) %>% mutate(y=x*(2+runif(100, 0, 10)), z=rep(c(1:10), 10))
tab <- modelsummary::modelsummary(
list("A very, very long title that will span multiple lines"=estimatr::lm_robust(data=df, clusters=z, y~x),
"A short title"=estimatr::lm_robust(data=df, y~x),
"A very, very long title that will span multiple lines"=estimatr::lm_robust(data=df, clusters=z, y~x),
"A short title"=estimatr::lm_robust(data=df, y~x)),
title = "This table should be on one landscape page in LaTeX with automatically adjusted column width and line breaks",
notes = c("A note that is very long and says many things and will span multiple lines where I would like automatic line breaks in LaTeX"),
output="kableExtra")
I now want to perform some kableExtra
manipulations:
tab %>%
add_header_above(c(" " = 1, "M1" = 1, "M2" = 1, "M3" = 2)) %>%
row_spec(3, color = 'red') %>%
row_spec(5, background = 'lightblue') %>%
column_spec(1, width="10.5cm")
I want to ensure that the table overall has the full page width (be it landscape or portrait) and line breaks automatically included. How do I best do this?
Further, I want save to .tex
. However, tab %>% ... %>% save_kable(format = "latex", file = "latex_table.tex")
gives an empty file. What am I doing wrong?
Can someone point me into the right direction? Thanks a lot.