title: How to return predicted values, residuals, R square from lm()?
body: <p>this piece of code will return coefficients :intercept , slop1 , slop2</p>
  
  <pre><code>set.seed(1)
  n=10
  
  y=rnorm(n)
  x1=rnorm(n)
  x2=rnorm(n)
  
  lm.ft=function(y,x1,x2)
    return(lm(y~x1+x2)$coef)
  
  res=list();
  for(i in 1:n){
    x1.bar=x1-x1[i]
    x2.bar=x2-x2[i]
    res[[i]]=lm.ft(y,x1.bar,x2.bar)
  }
  </code></pre>
  
  <p>If I type: </p>
  
  <pre><code>   &gt; res[[1]]
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>      (Intercept)          x1          x2 
       -0.44803887  0.06398476 -0.62798646 
  </code></pre>
  
  <p>How can we return predicted values,residuals,R square, ..etc?</p>
  
  <p>I need something general to extract whatever I need from the summary?</p>