rmodelsummary

Hide "Panel" row from rbinded modelsummary tables


Consider the following MWE:

mod <- lm(mpg~factor(cyl)*disp, mtcars)
fin1 <- marginaleffects::hypotheses(
  mod,
  "`factor(cyl)6`+`factor(cyl)6:disp`=0"
)
fin2 <- marginaleffects::hypotheses(
  mod,
  "`factor(cyl)8`+`factor(cyl)8:disp`=0"
)
fins <- list(fin1, fin2)
modelsummary::modelsummary(fins, stars=TRUE, gof_omit=".*", shape="rbind")

Which results in:

enter image description here

How can I hide the "Panel" rows?


Solution

  • Haven't found an option to achieve this in the docs. But one option to achieve your desired result would be to manipulate the table object returned by modelsummary like so, i.e.

    library(tinytable)
    library(modelsummary)
    
    mod <- lm(mpg ~ factor(cyl) * disp, mtcars)
    fin1 <- marginaleffects::hypotheses(
      mod,
      "`factor(cyl)6`+`factor(cyl)6:disp`=0"
    )
    fin2 <- marginaleffects::hypotheses(
      mod,
      "`factor(cyl)8`+`factor(cyl)8:disp`=0"
    )
    fins <- list(fin1, fin2)
    tab <- modelsummary::modelsummary(
      fins,
      stars = TRUE, gof_omit = ".*",
      shape = "rbind"
    )
    # Remove group rows
    tab@lazy_group <- list()
    tab |>
      # Set indent to 0 on first column
      tinytable::style_tt(
        j = 1,
        indent = 0
      ) |>
      # Add separator line
      tinytable::style_tt(
        i = 4, line = "b",
        line_color = "lightgrey", line_width = 0.05
      )
    

    enter image description here