title: How to have output from lm() include std. error and others without using summary() for stargazer
body: <p>I'm fitting several linear models in r in the following way:</p>
  <pre class="lang-r prettyprint-override"><code>set.seed(12345)
  n = 100
  x1 = rnorm(n)
  x2 = rnorm(n)+0.1
  y = x + rnorm(n)
  
  df &lt;- data.frame(x1, x2, y)
  x_str &lt;- c(&quot;x1&quot;, &quot;x1+x2&quot;)
  
  regf_lm &lt;- function(df,y_var, x_str ) {
    frmla &lt;- formula(paste0(y_var,&quot; ~ &quot;, x_str ))
    fit &lt;- lm(frmla, data = df ) 
    summary(fit) #fit
  }
  
  gbind_lm &lt;- function(vv) {
    n &lt;-  vv %&gt;% length()
    fits &lt;- list()
    coefs &lt;- list()
    ses &lt;- list()
    for (i in 1:n ) {
      coefs[[i]] &lt;- vv[[i]]$coefficients[,1]
      ses[[i]] &lt;- vv[[i]]$coefficients[,2]
      fits[[i]] &lt;- vv[[i]]
    }
    
    list(&quot;fits&quot; = fits, &quot;coefs&quot; = coefs, &quot;ses&quot; = ses)
  }
    
  stargazer_lm &lt;- function(mylist, fname, title_str,m_type = &quot;html&quot;,...) {
      stargazer(mylist$fits, coef =  mylist$coefs,
                se = mylist$ses,
                type = m_type, title = title_str, 
                out = paste0(&quot;~/projects/outputs&quot;,fname),  single.row = T ,...)
  }
  
  p_2 &lt;- map(x_str, 
             ~ regf_lm (df = df ,
                        y_var = &quot;y&quot;, x_str = .))
  m_all &lt;- do.call(c, list(p_2)) %&gt;% gbind_lm()
  stargazer_lm(m_all,&quot;name.html&quot;,&quot;My model&quot;, m_type = &quot;html&quot;)
  </code></pre>
  <p>In <code>regf_lm</code>, if I use <code>summary(fit)</code> on the last line, I'm able to generate reg output with columns for estimated coefficients, std. error, etc. But Stargazer() <a href="https://stackoverflow.com/questions/31857488/export-regression-table-with-stargazer-operator-is-invalid-for-atomic-vectors">does not work with summary(lm())</a> (returns <code>error $ operator is invalid for atomic vectors</code>). However, if I just use &quot;fit&quot; on the last line in <code>regf_lm</code>, the output shows only the estimated coefficients and not std error, R sq...and <code>gbind_lm()</code> won't work because I cannot extract ses or fit.</p>
  <p>Any advice is greatly appreciated.</p>