title: how to subtract certain column in R?
body: <p>I would like to subtract one certain column in R? How to do it?</p>
  
  <pre><code>vec &lt;- 1:20
  mat &lt;- matrix(vec,ncol=4)
  
  mat
       [,1] [,2] [,3] [,4]
  [1,]    1    6   11   16
  [2,]    2    7   12   17
  [3,]    3    8   13   18
  [4,]    4    9   14   19
  [5,]    5   10   15   20
  </code></pre>
  
  <p>for example, i would like to calculate the difference between 1th and 4th, 2th and 4th, 3th and 4th</p>
  
  <p>the results:</p>
  
  <pre><code>M1 &lt;- mat[,1]-mat[,4]
  
  M2 &lt;- mat[,2]-mat[,4]
  
  M3 &lt;- mat[,3]-mat[,4]
  nmat &lt;- data.frame(M1,M2,M3)
  nmat
  
     M1  M2 M3
  1 -15 -10 -5
  2 -15 -10 -5
  3 -15 -10 -5
  4 -15 -10 -5
  5 -15 -10 -5
  </code></pre>