title: Why is my custom function printing my row names in addition to the data?
body: <p>I have the following custom function that I am using to create a table of summary statistics in R.</p>
  <pre><code>regression.stats&lt;-function(fit){
    formula&lt;-fit$call;
    data&lt;-eval(getCall(fit)$data);
    abserror&lt;-abs(exp(fit$fitted.values)-data$bm)/exp(fit$fitted.values);
    QMLE&lt;-exp((sigma(fit)^2)/2);
    smear&lt;-sum(exp(fit$residuals))/nrow(data);
    RE&lt;-mean(data$bm)/mean(exp(fit$fitted.values));
    CF&lt;-(RE+smear+QMLE)/3;
    adjPE&lt;-mean(abs((exp(fit$fitted.values)*CF)-data$bm)
                 /(exp(fit$fitted.values)*CF));
    SEE&lt;-exp(sigma(fit)+4.6052)-100;
    summary&lt;-summary(fit)
    statistics&lt;-data.frame(&quot;df&quot;=fit$df.residual,
                       &quot;r2&quot;=round(summary(fit)$r.squared,4),
                       &quot;adjr2&quot;=round(summary(fit)$adj.r.squared,4),
                       &quot;AIC&quot;=AIC(fit),&quot;BIC&quot;=BIC(fit),
                       &quot;logLik&quot;=logLik(fit),
                       &quot;PE&quot;=round(mean(abserror)*100,2),QMLE=round(QMLE,3),
                       smear=round(smear,3),RE=round(RE,3),CF=round(CF,3),
                           &quot;adjPE&quot;=round(mean(adjPE)*100,2),
                           &quot;SEE&quot;=round(SEE,2),row.names = print(substitute(fit)));
  return(statistics)
  }
  </code></pre>
  <p>I want to bind the resulting rows into a data.frame in order to produce a table of comparison statistics between regression analyses. For example, using the data from the <code>mtcars</code> dataset...</p>
  <pre><code>data(mtcars)
  lm1&lt;-(cyl~mpg,data=mtcars)
  lm2&lt;-(cyl~disp,data=mtcars)
  lm2&lt;-(disp~mpg,data=mtcars)
  rbind(regression.stats(lm1),regression.stats(lm2),regression.stats(lm3))
  </code></pre>
  <p>I am creating this for an R Markdown html file and I want readers to be able to tell which regression equation produced which statistics. However when I run the code it also ends up printing a list of the names of the <code>lm</code> functions in addition to the regression statistics in the resulting html document.</p>
  <p>I have managed to track the problem down to the line <code>row.names = print(substitute(fit)))</code> in my function. If I remove that line it no longer prints the <code>lm</code> name when running the function. However, what happens then is my rows are no longer associated with the correct model name. <strong>How can I adjust my function so that it only prints the name of the model function as the row name of the summary function, rather than creating an additional list?</strong></p>