title: Subsetting a data.frame with an integer matrix
body: <p>I keep running into this and am wondering if there's an easy work-around.  For some situations I find it more logical to think about subsetting a matrix in </p>
  
  <pre><code>N &lt;- 12
  N.NA &lt;- 6
  dat &lt;- data.frame(V1=runif(N),V2=runif(N))
  sel.mat &lt;- matrix(c(sample(seq(N),N.NA),sample(ncol(dat),N.NA,replace=TRUE)),ncol=2)
  </code></pre>
  
  <p>This works for selection, but not for replacement:</p>
  
  <pre><code>&gt; dat[sel.mat]
  [1] 0.2582569 0.8455966 0.8828083 0.5384263 0.9574810 0.5623158
  &gt; dat[sel.mat] &lt;- NA
  Error in `[&lt;-.data.frame`(`*tmp*`, sel.mat, value = NA) : 
    only logical matrix subscripts are allowed in replacement
  </code></pre>
  
  <p>I realize that there's a reason for the error message (it wouldn't know what to do if you had multiple replacements pointing to the same element), but that doesn't stop R from allowing integer replacement on vectors (e.g. <code>dat$V1[c(2,3)] &lt;- NA</code>).</p>
  
  <p>Is there a convenient way to allow replacement by integer matrix?</p>