title: Array: subtract by row
body: <p>How can I subtract a vector of each row in a array?  </p>
  
  <pre><code>a &lt;- array(1:8, dim=c(2,2,2))
  a
  , , 1
  
        [,1] [,2]
  [1,]    1    3
  [2,]    2    4
  
  , , 2
  
         [,1] [,2]
  [1,]    5    7
  [2,]    6    8
  </code></pre>
  
  <p>Using apply gives me: </p>
  
  <pre><code>apply(a,c(1,2), '-',c(1,5))
  , , 1
  
        [,1] [,2]
  [1,]    0    1
  [2,]    0    1
  
  , , 2
  
        [,1] [,2]
  [1,]    2    3
  [2,]    2    3
  </code></pre>
  
  <p>What I am trying to get is: </p>
  
  <pre><code>, , 1
  
        [,1] [,2]
  [1,]    0   -2
  [2,]    1   -1
  
  , , 2
  
        [,1] [,2]
  [1,]    4    2
  [2,]    5    3
  </code></pre>
  
  <p>Thanks in advance for any hints</p>