Closed hhadah closed 5 months ago
I do not believe that modelsummary
has changed anything in its treatment of kableExtra
, but I can't be 100% sure because there were lots of changes in 2.0.0. Note that kableExtra
also had a few changes recently.
Your example is not reproducible and it is extremely complicated. Could you isolate the actually problematic behavior and supply a minimal reproducible example?
Here is a minimal reproducible example. The code runs perfectly until modelsummary
is pipped into kableExtra
function. It used to be the case that you could pipe a modelsummary(output="latex")
into the kableExtra
functions. Now the following code would produce the following error below. Editing modelsummary(output="latex")
to modelsummary(output="kableExtra")
would get the code to run but the save_kable
output becomes an empty latex document.
# Data for linear regression (using the mtcars dataset)
library(modelsummary)
library(kableExtra)
data(mtcars)
linear_model <- lm(mpg ~ wt + qsec, data = mtcars)
regression_tab <- modelsummary(
linear_model,
stars = c('***' = 0.01, '**' = 0.05, '*' = 0.1),
escape = F,
output = "latex") |>
kable_styling(latex_options = c("scale_down", "HOLD_position")) |>
footnote(number = c("\\\\footnotesize{Each column is the results of the extended two-way fixed effects estimation.
Standard errors are clustered on the county level.}"),
footnote_as_chunk = F, title_format = c("italic"),
escape = F, threeparttable = T, fixed_small_size = T)
regression_tab %>%
save_kable(file.path(tables_wd,"tab01-reg.tex"))
Error:
Error in if (kable_format %in% c("pipe", "markdown")) { :
argument is of length zero
Try:
options(modelsummary_factory_latex = "kableExtra")
and output="latex"
That did it! Thank you @vincentarelbundock for your help and the modelsummary
(and other functions). They are life savers!
Success!!
I am using the following code to create a latex table using
modelsummary
andkableExtra
. The code used to work but it seems that eithermodelsummary
orkableExtra
made some changes that made it harder to use both. Is there a way that editing the following table would result in a latex table being saved? I already tried changeoutput = "kableExtra"
and the latex table was empty.I used the modelsummary codes many times before and the product was an amazing latex table that could use in latex documents. I tried the code above that I ran many times before and was expecting the table to be saved in a script called
tab01-etwfe.tex
. Is there a way to fix this?Here is the code I am using
Doing the following edit produces a mutant latex document with html table
Output Table: