Search code examples
rmodelsummaryfixest

How to modify column labels with modelsummary


How can I modify the labelling scheme for the column labels (here: lhs: mpg and lhs: disp) with modelsummary?

According to the documentation, setting a global option like this options(modelsummary_model_labels = "roman") should change the labelling scheme but I do not see any effect.

library(fixest)
library(modelsummary)
options(modelsummary_model_labels = "roman")

mods <- feols(c(mpg, disp) ~ wt, data = mtcars)

modelsummary(mods)
lhs: mpg lhs: disp
(Intercept) 37.285 -131.148
(1.878) (35.717)
wt -5.344 112.478
(0.559) (10.635)
Num.Obs. 32 32
R2 0.753 0.789
R2 Adj. 0.745 0.781
AIC 164.0 352.5
BIC 167.0 355.5
RMSE 2.95 56.10
Std.Errors IID IID

Created on 2024-05-30 with reprex v2.1.0

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.0 (2024-04-24)
#>  os       macOS Sonoma 14.5
#>  system   aarch64, darwin20
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Europe/Berlin
#>  date     2024-05-30
#>  pandoc   3.1.11 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version    date (UTC) lib source
#>  backports      1.4.1      2021-12-13 [1] CRAN (R 4.4.0)
#>  bayestestR     0.13.2     2024-02-12 [1] CRAN (R 4.4.0)
#>  checkmate      2.3.1      2023-12-04 [1] CRAN (R 4.4.0)
#>  cli            3.6.2      2023-12-11 [1] CRAN (R 4.4.0)
#>  data.table     1.15.4     2024-03-30 [1] CRAN (R 4.4.0)
#>  datawizard     0.10.0     2024-03-26 [1] CRAN (R 4.4.0)
#>  digest         0.6.35     2024-03-11 [1] CRAN (R 4.4.0)
#>  dreamerr       1.4.0      2023-12-21 [1] CRAN (R 4.4.0)
#>  evaluate       0.23       2023-11-01 [1] CRAN (R 4.4.0)
#>  fansi          1.0.6      2023-12-08 [1] CRAN (R 4.4.0)
#>  fastmap        1.2.0      2024-05-15 [1] CRAN (R 4.4.0)
#>  fixest       * 0.12.0     2024-04-17 [1] CRAN (R 4.4.0)
#>  Formula        1.2-5      2023-02-24 [1] CRAN (R 4.4.0)
#>  fs             1.6.4      2024-04-25 [1] CRAN (R 4.4.0)
#>  generics       0.1.3      2022-07-05 [1] CRAN (R 4.4.0)
#>  glue           1.7.0      2024-01-09 [1] CRAN (R 4.4.0)
#>  htmltools      0.5.8.1    2024-04-04 [1] CRAN (R 4.4.0)
#>  insight        0.19.11    2024-05-12 [1] CRAN (R 4.4.0)
#>  knitr          1.46       2024-04-06 [1] CRAN (R 4.4.0)
#>  lattice        0.22-6     2024-03-20 [1] CRAN (R 4.4.0)
#>  lifecycle      1.0.4      2023-11-07 [1] CRAN (R 4.4.0)
#>  magrittr       2.0.3      2022-03-30 [1] CRAN (R 4.4.0)
#>  modelsummary * 2.0.0      2024-03-31 [1] CRAN (R 4.4.0)
#>  nlme           3.1-164    2023-11-27 [1] CRAN (R 4.4.0)
#>  numDeriv       2016.8-1.1 2019-06-06 [1] CRAN (R 4.4.0)
#>  parameters     0.21.7     2024-05-14 [1] CRAN (R 4.4.0)
#>  performance    0.11.0     2024-03-22 [1] CRAN (R 4.4.0)
#>  purrr          1.0.2      2023-08-10 [1] CRAN (R 4.4.0)
#>  R.cache        0.16.0     2022-07-21 [1] CRAN (R 4.4.0)
#>  R.methodsS3    1.8.2      2022-06-13 [1] CRAN (R 4.4.0)
#>  R.oo           1.26.0     2024-01-24 [1] CRAN (R 4.4.0)
#>  R.utils        2.12.3     2023-11-18 [1] CRAN (R 4.4.0)
#>  Rcpp           1.0.12     2024-01-09 [1] CRAN (R 4.4.0)
#>  reprex         2.1.0      2024-01-11 [1] CRAN (R 4.4.0)
#>  rlang          1.1.3      2024-01-10 [1] CRAN (R 4.4.0)
#>  rmarkdown      2.27       2024-05-17 [1] CRAN (R 4.4.0)
#>  rstudioapi     0.16.0     2024-03-24 [1] CRAN (R 4.4.0)
#>  sandwich       3.1-0      2023-12-11 [1] CRAN (R 4.4.0)
#>  sessioninfo    1.2.2      2021-12-06 [1] CRAN (R 4.4.0)
#>  stringmagic    1.1.2      2024-04-30 [1] CRAN (R 4.4.0)
#>  styler         1.10.3     2024-04-07 [1] CRAN (R 4.4.0)
#>  tables         0.9.25     2024-04-13 [1] CRAN (R 4.4.0)
#>  tinytable      0.2.1      2024-03-28 [1] CRAN (R 4.4.0)
#>  vctrs          0.6.5      2023-12-01 [1] CRAN (R 4.4.0)
#>  withr          3.0.0      2024-01-16 [1] CRAN (R 4.4.0)
#>  xfun           0.44       2024-05-15 [1] CRAN (R 4.4.0)
#>  yaml           2.3.8      2023-12-11 [1] CRAN (R 4.4.0)
#>  zoo            1.8-12     2023-04-13 [1] CRAN (R 4.4.0)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Solution

  • This global option only affects situations when mods is an unnamed list. Your fixest command is a special case that returns a named list. You can remove the names manually to get roman numerals:

    library(fixest)
    library(modelsummary)
    options(modelsummary_model_labels = "roman")
    mods <- feols(c(mpg, disp) ~ wt, data = mtcars)
    mods <- as.list(mods)
    names(mods) <- NULL
    modelsummary(mods)