title: Gluing objects imported to a modelsummary table
body: <p>This is a follow-up question from a previous one: <a href="https://stackoverflow.com/questions/69582118/extracting-information-from-r-objects-and-importing-it-to-a-modelsummary-table/69584159">Extracting information from R objects and importing it to a modelsummary table</a></p>
  <p>I would like to know how I could glue the F statistic and associated stars that are imported to a <code>modelsummary</code> table with <code>glance_custom.lm_robust</code> and <code>gof_map</code>.</p>
  <p>Here are some more details.</p>
  <p>Following Vincent's extremely helpful advice and suggestions, I made the model summary table below using the <code>modelsummary</code> package, incorporating the F statistics and associated p-values for some models which were picked manually.</p>
  <pre><code>library(modelsummary)
  library(estimatr)
  library(tibble)
  library(car)
  
  mod1 &lt;- lm_robust(mpg ~ am + vs, mtcars)
  mod2 &lt;- lm_robust(mpg ~ am + vs + hp, mtcars)
  mod3 &lt;- lm_robust(mpg ~ am + vs + wt, mtcars)
  mod4 &lt;- lm_robust(mpg ~ am + vs + qsec, mtcars)
  
  # models 2 and 4 will have a linear hypothesis test
  attr(mod2, &quot;FTEST&quot;) &lt;- TRUE
  attr(mod4, &quot;FTEST&quot;) &lt;- TRUE
  
  glance_custom.lm_robust &lt;- function(x) {
    # check if we should include the linear hypothesis test in this specific model
    if (!isTRUE(attr(x, &quot;FTEST&quot;))) return(NULL)
  
    # conduct linear hypothesis test
    ftest &lt;- linearHypothesis(x, test = &quot;F&quot;, c(&quot;am = 0&quot;, &quot;vs = 0&quot;))
  
    # return a 1-row tibble with each statistic in separate columns
    out &lt;- tibble(
      &quot;ftestF&quot; = ftest[[&quot;F&quot;]][2], 
      &quot;ftestP&quot; = sprintf(&quot;(%.3f)&quot;, ftest[[&quot;Pr(&gt;F)&quot;]][2]), 
      &quot;ftestStars&quot; = if (ftest[[&quot;Pr(&gt;F)&quot;]][2] &lt;= 0.01) {
        &quot;***&quot;
      } else if (ftest[[&quot;Pr(&gt;F)&quot;]][2] &lt;= 0.05) {
        &quot;**&quot;
      } else if (ftest[[&quot;Pr(&gt;F)&quot;]][2] &lt;= 0.1) {
        &quot;*&quot;
      } else {
        NULL
      }
      )
    return(out)
  }
  
  gm &lt;- tribble(
    ~raw, ~clean, ~fmt,
    &quot;ftestF&quot;, &quot;$H_0: \\beta_{\\rm{am}} = 0, \\ \\beta_{\\rm{vs}} = 0$&quot;, 3,
    &quot;ftestP&quot;, &quot;XXXP&quot;, 0,
    &quot;ftestStars&quot;, &quot;XXXStars&quot;,  0,
    &quot;adj.r.squared&quot;, &quot;$\\bar{R}^2$&quot;, 3,
    &quot;nobs&quot;, &quot;Sample size&quot;, 0
  )
  
  modelsummary(
    list(mod1, mod2, mod3, mod4), escape = FALSE, 
    estimate = &quot;{estimate}{stars}&quot;, 
    stars = c('***' = .01, '**' = .05, '*' = .1), 
    gof_map = gm
    )
  </code></pre>
  <p><a href="https://i.stack.imgur.com/GscVl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GscVl.png" alt="Model summary table" /></a></p>
  <p>This is very close to what I want. However, I want to show the significance stars for the F test not in a separate line but next to the F statistics, just as significance stars are shown next to the regression coefficients. I tried to glue <code>&quot;ftestF&quot;</code> and <code>&quot;ftestStars&quot;</code> in <code>gm</code> but did not succeed. I would be grateful for any advice.</p>
  <p>I also want to eliminate the line headings <code>XXXP</code> and <code>XXXStars</code> (I guess <code>XXXStars</code> would disappear once my question in the previous paragraph was solved). Replacing <code>&quot;XXXP&quot;</code> with <code>&quot;&quot;</code> (or <code>&quot; &quot;</code>) did make the line heading disappear but the p-values (0.000) and the stars moved to unexpected locations. I would appreciate any advice on this as well.</p>