1

I wonder is it possible to remove model names entirely (and delete the row in the table). I tried setting them to NULL but that does not seem to work.

library(modelsummary)
x<-rnorm(5)
y<-rnorm(5)

models<-list(lm(y~x),lm(y~x))
names(models)<-NULL

#This still produces models with names
modelsummary(models)
Vitalijs
  • 938
  • 7
  • 18

2 Answers2

0

An option may be to set the names to blank ("")

names(models) <- rep("", length(models))
modelsummary(models)

-output

enter image description here


Deleting row - if it is coefficient, use `coef_omit

modelsummary(models, coef_omit = "x")

enter image description here

and if there are other parameters to be removed, can also use a regex in gof_omit

modelsummary(models, gof_omit = "AIC|BIC")

enter image description here

akrun
  • 874,273
  • 37
  • 540
  • 662
  • this is an excellent answer. But not exactly what I want, I really want to remove it physically, because after I do: ```add_header_above(c(" " = 1, "Probability of Exit" = 4),line = FALSE) %>%``` and if I do not remove it, there is an empty space. – Vitalijs Nov 22 '21 at 17:03
  • @Vitalijs wouldn't this be the names of the models, i.e. `setNames(models, ...)` before you apply `modelsummary` – akrun Nov 22 '21 at 17:04
0

In the development version of modelsummary (version >0.9.4), all the extra arguments that you pass to modelsummary will be pushed through the ellipsis (...) automatically to kableExtra::kbl(). This means that you can use the col.names=NULL argument to get this:

library(remotes)
install_github("vincentarelbundock/modelsummary")

library(modelsummary)

mod <- list(
    lm(mpg ~ hp, mtcars),
    lm(mpg ~ hp + drat, mtcars)
)

modelsummary(mod, col.names = NULL)

enter image description here

Vincent
  • 15,809
  • 7
  • 37
  • 39