title: How to avoid dropping a dimension in linear model residuals?
body: <p>In R, <code>lm(...)$residuals</code> if passed a matrix response returns a matrix with same column names as the response, <em>unless</em> the matrix has only one column, in which case it drops down to a vector and hence no column name is present.  For example:</p>
  
  <pre><code>nc &lt;- 1
  Y &lt;- matrix(rnorm(4*nc), ncol = nc, dimnames = list(NULL, letters[1:nc]))
  colnames(lm(Y~1)$residual) # returns NULL
  nc &lt;- 2
  Y &lt;- matrix(rnorm(4*nc), ncol = nc, dimnames = list(NULL, letters[1:nc]))
  colnames(lm(Y~1)$residual) # returns c("a", "b")
  </code></pre>
  
  <p>Is there some way to avoid this (akin to <code>drop=F</code>) so the residuals preserve the column names?  (Obviously one approach is to add them back in again manually.)</p>