Putting my regression results (3 regression results) into one table using R

Here are the packages I have installed and loaded:

knitr::opts_chunk$set(echo = TRUE)
setwd("/Users/Anon/Desktop/Anon")
install.packages("modelsummary")
install.packages("kableExtra")
install.packages("dplyr")
install.packages("stargazer")
install.packages("tinytex")
install.packages("tinytable")
install.packages("tidyverse")
config_modelsummary(factory_default = 'tinytable')
library(tidyverse)
library(modelsummary)
library(modelsummary)
library(kableExtra)
library(fpp3)
library(stringr)
library(dplyr)
library(GGally)
library(stargazer)

Here is the part of my code I am struggling with:

list("All" = Results_whole, 
     "Port Phillip" = Results_whole,
     "Melbourne" = airbnb_Melbourne) %>% 
 msummary(stars = TRUE) %>%
 kable_styling(latex_options = "HOLD")

Here is the error I get:

Error: `modelsummary could not extract the required information from a model of class "tbl_df". The package tried
  a sequence of 2 helper functions to extract estimates:
  
  parameters::parameters(model)
  broom::tidy(model)
  
  To draw a table, one of these commands must return a `data.frame` with a column named "term". The
  `modelsummary` website explains how to summarize unsupported models or add support for new models yourself:
  https://modelsummary.com/articles/modelsummary.html
  
  These errors messages were generated during extraction:
  
  `parameters::parameters(model)` did not return a valid data.frame.
`broom::tidy(model)` did not return a valid data.frame.
In addition: Warning message:
`modelsummary could not extract goodness-of-fit statistics from a model
of class "tbl_df". The package tried a sequence of 2 helper functions:

performance::model_performance(model)
broom::glance(model)

One of these functions must return a one-row `data.frame`. The `modelsummary` website explains how to summarize unsupported models or add support for new models yourself:

https://modelsummary.com/articles/modelsummary.html

Output of sessionInfo():

R version 4.3.2 (2023-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.3.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Australia/Melbourne
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] stargazer_5.2.3    GGally_2.2.1       fable_0.3.3        feasts_0.3.2       fabletools_0.4.0   tsibbledata_0.4.1 
 [7] tsibble_1.1.4      fpp3_0.5           kableExtra_1.4.0   modelsummary_1.4.5 lubridate_1.9.3    forcats_1.0.0     
[13] stringr_1.5.1      dplyr_1.1.4        purrr_1.0.2        readr_2.1.5        tidyr_1.3.1        tibble_3.2.1      
[19] ggplot2_3.5.0      tidyverse_2.0.0   

loaded via a namespace (and not attached):
 [1] tidyselect_1.2.0     viridisLite_0.4.2    farver_2.1.1         fastmap_1.1.1        bayestestR_0.13.2   
 [6] digest_0.6.34        timechange_0.3.0     estimability_1.5     lifecycle_1.0.4      ellipsis_0.3.2      
[11] magrittr_2.0.3       compiler_4.3.2       rlang_1.1.3          tools_4.3.2          utf8_1.2.4          
[16] yaml_2.3.8           knitr_1.45           labeling_0.4.3       bit_4.0.5            plyr_1.8.9          
[21] xml2_1.3.6           RColorBrewer_1.1-3   tinytable_0.1.0      withr_3.0.0          grid_4.3.2          
[26] datawizard_0.9.1     fansi_1.0.6          colorspace_2.1-0     emmeans_1.10.0       scales_1.3.0        
[31] insight_0.19.8       cli_3.6.2            mvtnorm_1.2-4        anytime_0.3.9        rmarkdown_2.25      
[36] crayon_1.5.2         generics_0.1.3       rstudioapi_0.15.0    performance_0.10.9   tzdb_0.4.0          
[41] parameters_0.21.5    parallel_4.3.2       effectsize_0.8.6     vctrs_0.6.5          hms_1.1.3           
[46] bit64_4.0.5          systemfonts_1.0.5    glue_1.7.0           ggstats_0.5.1        distributional_0.4.0
[51] stringi_1.8.3        gtable_0.3.4         tables_0.9.17        lmtest_0.9-40        munsell_0.5.0       
[56] pillar_1.9.0         rappdirs_0.3.3       htmltools_0.5.7      R6_2.5.1             vroom_1.6.5         
[61] evaluate_0.23        lattice_0.21-9       backports_1.4.1      broom_1.0.5          Rcpp_1.0.12         
[66] svglite_2.1.3        coda_0.19-4.1        checkmate_2.3.1      xfun_0.42            zoo_1.8-12          
[71] pkgconfig_2.0.3 

I tried to present 3 regression results into one table, in a list and piped them into msummary(), using the code listed above. i expected to get one table that tabulated the results of the three regressions. I got an error message about the "modelsummary" package, which i have pasted above.

I think the key part of the error message is this sentence:

This suggests that at least one of your tables is missing the column "term". Could you please run the following and report the results?

is.data.frame(Results_whole)
"term" %in% colnames(Results_whole)
is.data.frame(airbnb_Melbourne)
"term" %in% colnames(airbnb_Melbourne)

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.