vincentarelbundock / modelsummary

Beautiful and customizable model summaries in R.
http://modelsummary.com
Other
893 stars 73 forks source link

Alignment issues with panels, add_rows, and coef_omit together #783

Open lrose1 opened 2 weeks ago

lrose1 commented 2 weeks ago

This seems to be specific to using all three at the same time. Say I want to add extra rows in two panels, but also get rid of some coefficients:

library(modelsummary)
library(tibble)

rows <- tribble(~term, ~OLS,  ~Logit,
                'Info', '???', 'XYZ',
                'Info', '???', 'XYZ',
                'Info', '???', 'XYZ',
                'Info', '???', 'XYZ')
attr(rows, 'position') <- c(5,6, 12,13)

gm <- c("r.squared", "nobs", "rmse")

panels <- list(
  list(
    lm(mpg ~ 1, data = mtcars),
    lm(mpg ~ qsec, data = mtcars)
  ),
  list(
    lm(hp ~ 1, data = mtcars),
    lm(hp ~ qsec, data = mtcars)
  )
)

modelsummary(
  coef_omit = -1,
  panels,
  shape = "rbind",
  gof_map = gm, add_rows = rows)

The issue goes away if coef_omit is not used.

vincentarelbundock commented 2 weeks ago

Thanks a lot for taking the time to file this report and craft a reproducible example. Ideally appreciate it.

I'll take a look as soon as I can, but it might take a little while, because I'm busy at the day job these days.

lrose1 commented 2 weeks ago

Totally understand, I'm a big fan of your work in that job too.