title: R error incorrect number of subscripts on matrix
body: <p>I am a beginner in R. I have two matrices with the same number of rows (let's say 10), and many columns. I want to do a linear regression, using glm, between eacg row of matrixA and the corresponding row of matrixB. I want to print the residuals in a new matrix, which will have the same number of rows as the original matrices:</p>
  
  <pre><code>matrixA &lt;- read.table("fileA.txt", header=TRUE, row.names=1)
  matrixB &lt;- read.table("fileB.txt", header=TRUE, row.names=1)
  
  for(i in 1:10) {
      response = as.matrix(matrixA)[i,]
      predictor = as.matrix(matrixB)[i,]
      fit &lt;- glm(response ~ predictor)
      residuals[i,] &lt;- fit$residuals
  }
  </code></pre>
  
  <p>However, I am getting this error:</p>
  
  <pre><code>Error in residuals[1, ] &lt;- fit$residuals : 
    incorrect number of subscripts on matrix
  </code></pre>
  
  <p>I looked up this error a bit, and thought that maybe it did not recognize fit$residuals as a vector, so I tried to specify it (as.vector(fit$residuals)), but that did not fix it.</p>
  
  <p>Any idea on how I can fix this? Thank you!</p>
  
  <p>Format of the matrices (both have the same format)</p>
  
  <pre><code>    a   b   c   d   f
  A   1.0 2.0 3.0 4.0 5.0
  B       …
  C
  D
  E
  F
  G
  H
  I
  J
  </code></pre>