title: Robust Standard Errors in lm() using stargazer()
body: <p>I have read a lot about the pain of replicate the easy robust option from STATA to R to use robust standard errors. I replicated following approaches: <a href="https://stats.stackexchange.com/questions/117052/replicating-statas-robust-option-in-r/117066?newreg=56d3029c56e0476a9061f8fb64380c35">StackExchange</a> and <a href="https://economictheoryblog.com/2016/08/07/robust-standard-errors-in-r-function/" rel="noreferrer">Economic Theory Blog</a>. They work but the problem I face is, if I want to print my results using the <code>stargazer</code> function (this prints the <code>.tex</code> code for Latex files).</p>
  
  <p>Here is the illustration to my problem:</p>
  
  <pre><code>reg1 &lt;-lm(rev~id + source + listed + country , data=data2_rev)
  stargazer(reg1)
  </code></pre>
  
  <p>This prints the R output as .tex code (non-robust SE) If i want to use robust SE, i can do it with the sandwich package as follow:</p>
  
  <pre><code>vcov &lt;- vcovHC(reg1, "HC1")
  </code></pre>
  
  <p>if I now use stargazer(vcov) only the output of the vcovHC function is printed and not the regression output itself.</p>
  
  <p>With the package <code>lmtest()</code> it is possible to print at least the estimator, but not the observations, R2, adj. R2, Residual, Residual St.Error and the F-Statistics.</p>
  
  <pre><code>lmtest::coeftest(reg1, vcov. = sandwich::vcovHC(reg1, type = 'HC1'))
  </code></pre>
  
  <p>This gives the following output:</p>
  
  <pre><code>t test of coefficients:
  
              Estimate Std. Error t value Pr(&gt;|t|)   
  (Intercept) -2.54923    6.85521 -0.3719 0.710611   
  id           0.39634    0.12376  3.2026 0.001722 **
  source       1.48164    4.20183  0.3526 0.724960   
  country     -4.00398    4.00256 -1.0004 0.319041   
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  </code></pre>
  
  <p>How can I add or get an output with the following parameters as well?</p>
  
  <pre><code>Residual standard error: 17.43 on 127 degrees of freedom
  Multiple R-squared:  0.09676,   Adjusted R-squared:  0.07543 
  F-statistic: 4.535 on 3 and 127 DF,  p-value: 0.00469
  </code></pre>
  
  <p>Did anybody face the same problem and can help me out? 
  How can I use robust standard errors in the <code>lm</code> function and apply the <code>stargazer</code> function?</p>