title: R: Converting do.call()-summary in summary
body: <p>As the <code>stepAIC()</code> function from the <code>MASS</code> package has problems when used within a function, I use it with <code>do.call()</code> (described <a href="https://stackoverflow.com/questions/9161273/use-stepaic-on-a-list-of-models">here</a>).
  My problem sounds very easy but I could't find a solution for it: When I use <code>do.call()</code> for a <code>lm()</code> model with several raster layers, all the layers are saved within the model. If I want to print a <code>summary()</code> of the model, it writes all the layers in the output and it gets really confusing. How do I get a "normal" <code>summary</code> output, as I would get without using <code>do.call</code>?</p>
  
  <p>Here is a short example:</p>
  
  <p>Create a list of raster layers:</p>
  
  <pre><code>xz.list  &lt;- lapply(1:5,function(x){
    r1 &lt;- raster(ncol=3, nrow=3)
    values(r1) &lt;- 1:ncell(r1)
    r1
  })
  </code></pre>
  
  <p>Convert them in a <code>data.frame</code>:</p>
  
  <pre><code>xz&lt;-getValues(stack(xz.list))
  
  xz &lt;- as.data.frame(xz)
  </code></pre>
  
  <p>Use <code>do.call</code> for the <code>lm</code> model:</p>
  
  <pre><code>fit1&lt;-do.call("lm", list(xz[,1] ~ . , data = xz))
  </code></pre>
  
  <p>The <code>summary()</code> output looks like this:</p>
  
  <pre><code>summary(fit1)
  
  Call:
  lm(formula = xz[, 1] ~ ., data = structure(list(layer.1 = 1:9, 
      layer.2 = 1:9, layer.3 = 1:9, layer.4 = 1:9, layer.5 = 1:9), .Names = c("layer.1", 
  "layer.2", "layer.3", "layer.4", "layer.5"), row.names = c(NA, 
  -9L), class = "data.frame"))
  
  Residuals:
         Min         1Q     Median         3Q        Max 
  -9.006e-16 -2.472e-16 -2.031e-16 -1.370e-16  1.724e-15 
  
  Coefficients: (4 not defined because of singularities)
               Estimate Std. Error   t value Pr(&gt;|t|)    
  (Intercept) 1.184e-15  5.784e-16 2.047e+00   0.0798 .  
  layer.1     1.000e+00  1.028e-16 9.729e+15   &lt;2e-16 ***
  layer.2            NA         NA        NA       NA    
  layer.3            NA         NA        NA       NA    
  layer.4            NA         NA        NA       NA    
  layer.5            NA         NA        NA       NA    
  ---
  Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
  
  Residual standard error: 7.962e-16 on 7 degrees of freedom
  Multiple R-squared:     1,  Adjusted R-squared:     1 
  F-statistic: 9.465e+31 on 1 and 7 DF,  p-value: &lt; 2.2e-16 
  </code></pre>
  
  <p>This doesn't look to bad in this small example, but it becomes a mess when you are using 10 or more <code>raster</code> layers with about 32k values each. So I would like to make the output look like as I would just use the <code>summary(lm)</code> function without <code>do.call</code>:</p>
  
  <pre><code>fit&lt;-lm(xz[,1] ~ . , data=xz)
  summary(fit)
  
  Call:
  lm(formula = xz[, 1] ~ ., data = xz)
  
  Residuals:
         Min         1Q     Median         3Q        Max 
  -9.006e-16 -2.472e-16 -2.031e-16 -1.370e-16  1.724e-15 
  
  Coefficients: (4 not defined because of singularities)
               Estimate Std. Error   t value Pr(&gt;|t|)    
  (Intercept) 1.184e-15  5.784e-16 2.047e+00   0.0798 .  
  layer.1     1.000e+00  1.028e-16 9.729e+15   &lt;2e-16 ***
  layer.2            NA         NA        NA       NA    
  layer.3            NA         NA        NA       NA    
  layer.4            NA         NA        NA       NA    
  layer.5            NA         NA        NA       NA    
  ---
  Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
  
  Residual standard error: 7.962e-16 on 7 degrees of freedom
  Multiple R-squared:     1,  Adjusted R-squared:     1 
  F-statistic: 9.465e+31 on 1 and 7 DF,  p-value: &lt; 2.2e-16 
  </code></pre>