Home > Software design >  Removing model names in modelsummary
Removing model names in modelsummary

Time:11-23

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)

CodePudding user response:

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

CodePudding user response:

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

  • Related