title: Matrix - Select everything except specified indices
body: <p>I know that you can directly select the indices of a matrix you want by doing:</p>
  
  <pre><code>mat &lt;- matrix(1:6,ncol=3)
  select &lt;- matrix(c(1,2,1,2,3,3),ncol=2)
  colnames(select) = c("row","col")
  
  mat[select]
  #[1] 3 6 5
  </code></pre>
  
  <p>Is there a way in R to select all the elements in a matrix except specific indices? This is allowed easily for vectors with <code>LETTERS[-1]</code>. Ideally, I could do something like <code>mat[-select]</code>, but when trying this, I get:</p>
  
  <pre><code>mat[-select]
  #Error in mat[-select] : 
  #  negative values are not allowed in a matrix subscript
  </code></pre>
  
  <p>What I've tried:</p>
  
  <pre><code>library(dplyr)
  all_ind &lt;- expand.grid(row=1:nrow(mat),col=1:ncol(mat))
  keep&lt;-anti_join(all_ind,as.data.frame(select))
  
  mat[as.matrix(keep)]
  #[1] 4 2 1
  </code></pre>
  
  <p>This works, but it requires some coercion and joining which isn't ideal. Maybe it's just me, but I couldn't seem to find any easy approaches to this.</p>